-
Notifications
You must be signed in to change notification settings - Fork 60
The IO object is two things at once: A pub-sub system, and a container for two queues: in
and out
(both functionally the same.)
#IO
##register ( name, fun, [thisArg [, arg0, arg1, ...]] )
Register an event handler (fun
) for the name
event. When fired, it will be called with thisArg
as the this
value, and any arguments passed after thisArg
will also be passed into the handler.
If a handler returns false
, then IO.preventDefault
is set to true
.
##unregister ( name, fun )
Remove fun
from the event handler queue for the event name
.
##fire( name [, arg0, arg1, ...] )
Fire the event name
. Optionally pass any other arguments to the event handler(s).
##jsonp ( opts ) Launch a jsonp request. There are currently differences between the client-side version of the bot and the server side, so until the unification this should be left partially undocumented. The source is plain and simple, so sniff around.
##loadScript ( url )
(Client-Side Only) Load a js script with a url of url
. Basically just sticks a script
tag on the head
.
##events An object containing the events and their handlers. Used internally, should be used externally.
##preventDefault A boolean value indicating whether an event handler returned false.
#IO.in, IO.out Two objects, wrapping around a buffer, used for general IO. They are built the same way, function the same, but their buffers are not shared.
##receive ( obj )
Appends obj
to the buffer.
Before the appending occurs, a receiveinput
or receiveoutput
event is fired with obj
passed as an argument. If IO.preventDefault
was switched on after the event call, the appending will not occur.
##tick ()
Fires an input
or output
event, passing the first item in the buffer as an argument. The first item in the buffer will be removed.
##flush ()
Unloads the entire buffer, doing the same thing as tick
for each item.
Before the unloading occurs, a beforeoutput
or beforeinput
event is fired. After it is finished, afteroutput
and beforeoutput
are fired.