ID:2698014
 
Applies to:Dream Maker
Status: Open

Issue hasn't been assigned a status value.
Output() can be used to send messages to js functions, we use this heavily at /tg/ for our rich react based interfaces.

The complex nature of the data sent back and forth means we have to json_encode() it and pass that as the first argument.

Since output requires url_encoded params, the extra (and unneeded) trips thru the string tree causes this to randomly take on the order of 300 milliseconds, (even when accounting for message length, the same length can take under a millisecond, or randomly 100-300 milliseconds).

In the time since output() to browsers was created, BYOND has gained native json support, and can now leverage it to support sending objects (or more likely, just json) to js functions (as the only argument) when lists are directly passed to output(). This kind of pattern for js functions is already common as a way to emulate named arguments.

example:

output(list("foo" = "bar"), ":browser:dothing")


function dothing(json) {
var arguments = JSON.parse(json)
}


If you want to also support sending positional arguments this way also works:

output(list("blah", list("foo" = "bar")), ":browser:dothing")


function dothing(operation, json) {
var arguments = JSON.parse(json)
}

(here, the idea is BYOND would json_encode any inner lists, (only up to 1 depth, since json_encode would handle the deeper depths of lists), and pass each json/string/etc in the list as arguments to the js function.)


(alternatively, add websocket support)
Bump, pls
This would be a godsend for complex interfaces.
bump