Messaging
How to send & receive inter-control messages
Functions
OAT.MSG.send(sender,
message, event)
Dispatches a message.
-
sender - to object sending this message.
-
message - a constant, defined in OAT.MSG.
Developers are encouraged to add more message types. Examples
include OAT_LOAD,TREE_EXPAND, and AJAX_FAILURE.
-
event - an object carrying data relevant to this
message; no particular format is required.
OAT.MSG.attach(sender,
message, callback)
Subscribes to messages.
-
sender - the object whose messages we want to
receive; value of "*" means ALL senders.
-
message - the message we want to receive; it is
possible to use "*" or RegExpmatches here.
-
callback - When a message arrives, callback is
executed with arguments passed to appropriate
OAT.MSG.send()function.
OAT.MSG.detach(sender,
message, callback)
Detaches previously set message receiving handler. All three
fields must match.
Example
/* assume that there exists OAT.MSG.CUSTOM_MESSAGE */
function myMessageHandler(source, message, event) {
alert("Message arrived!"(;
}
/* subscribe to receiving... */
OAT.MSG.attach("*","CUSTOM_.*",myMessageHandler);
/* dispatch message */
OAT.MSG.send(this, OAT.MSG.CUSTOM_MESSAGE, {}); // will invoke myMessageHandler