(API) Event

  • plamzi
  • plamzi's Avatar Topic Author
  • Offline
  • Administrator
More
09 Nov 2013 20:09 - 01 Dec 2014 13:50 #1 by plamzi
(API) Event was created by plamzi
Event is a single object acting as a notification center. Modules subscribe to be notified when certain events take place.

Example Use:
var c = new Colorize();
Event.listen('before_display', c.colorize);

The above code block creates an instance of the "Colorize" module and subscribes the public method "colorize" to the "before_display" event. When that event fires, "colorize" will be called, and will get a chance to transform the incoming data.

METHODS:
Event.listen('before_process', mymodule.preprocess);Subscribes the public function "preprocess" in "mymodule" to the earliest available server data. The function "preprocess" needs to return the data it wants to be passed on, otherwise no data will reach the user.
Event.drop('before_process', MyModule.preprocess);Unsubscribes the public function "preprocess" in "MyModule" from the event 'before_process'.
Event.create('my_event');Creates a new queue for the custom event 'my_event'.
Event.fire('my_event'[, data, caller]);Fires the event 'my_event'. Optionally, it can pass any arguments to the subscribers. The example shows data, and the caller, being passed.
Event.destroy('my_event');Destroys the event 'my_event', dropping all existing listeners. Future subscribers will be told that this event doesn't exist. Note that you can destroy any of the built-in events listed below if your customizations call for it.

EVENTS:
socket_open | socket_before_close | socket_closeGet notified on major socket events. Note that this is the Websocket running on the app page and (usually) connecting to the server-side proxy.
before_processIntercept and alter incoming server data in its "raw" state, before any built-in manipulations.
after_protocolsAfter all protocol data (GMCP, MXP, etc) has been processed and stripped from the incoming server data.
before_htmlFires after the above, and right before the app transforms the input into html text, e. g. by using <span> tags to colorize it.
before_displayAlter server data after other transformations have taken place, and right before the server data is displayed to the user.
after_displayCalled after a new chunk of data was displayed. Data cannot be altered at this stage but additional work can be done. For instance, the trigger module subscribes to this event in order to kick off triggers after the user has seen the text that kicked off a trigger.
before_sendAllows you to alter the user input prior to being sent to the server. The alias / macro module uses this event. This fires only on user input, not on all data sent to the server.
msdpAllows a module to intercept and process any received MSDP data. The data is always a 1D array.
gmcpAllows a module to intercept and process any received GMCP (ATCP2) data. The incoming string is not pre-parsed in any way.
atcpAllows a module to intercept and process any received ATCP data. The incoming string is not pre-parsed in any way.
mxp_entityForwards an array of the data elements sent by the server inside an MXP Entity tag.
mxp_frameForwards information about a frame created after an MXP frame tag was received by the server.
scrollview_readyNotifies listeners that the ScrollView has finished loading. At that point, you can use its public methods such as "Config.ScrollView.button" to add a button to its toolbar.
scrollview_addNotifies listeners that the ScrollView has added HTML content. The first argument is the formatted HTML that was added. This is useful for echoing the formatted output to plugins.
chatterbox_readyNotifies that the ChatterBox window has finished loading. At that point, you can use its public methods such as Config.ChatterBox.tab to add a tab with your own content.
window_open | window_close | window_front | window_hide | window_showEvents fired by every Window when key events occur. The first argument is the id of the window.
Last edit: 01 Dec 2014 13:50 by plamzi.
The topic has been locked.