class
SAPO.Utility.Mediator
_mediatorSubscribers is an *global* array of [subscriberContext, subscriberFn]
Can be used by invoking the Mediator singleton directly OR, after installTo has been called on an object, calling the API there.
If the cbFn is ommitted on subscribe(), looks for 'onMsgType' and 'on' methods on the caller context|subscriberOverride.
Version:
0.1
TODO: implement subscribeOnce (did not do it yet because I have no need for it)
Since:
Defined in
Utility/Mediator/0.1/lib.js
December 2012
Function Summary
publishes a message to all the subscribers, asynchronously
adds the API to the given object (mixin)
publish()
alias of emit. see its signature.
alias of emitDelayed. see its signature.
erases any listener information (use with caution!)
subscribes
Function Details
function emit
emit(String
msgType)
publishes a message to all the subscribers
Parameters:
msgType
a string defining which subscriber list will get the given message
the remaining arguments are optional. the whole arguments list is passed on to the subscribed callback functions function emitDelayed
emitDelayed([Number
ms], String
msgType)
publishes a message to all the subscribers, asynchronously
Parameters:
[ms]
number of millisseconds before the message is sent. if ommitted assumes 0.
msgType
a string defining which subscriber list will get the given message
the remaining arguments are optional. the whole arguments list is passed on to the subscribed callback functions function installTo
installTo(Object
o, Object
opts)
adds the API to the given object (mixin)
Parameters:
o
object to enrich with API
opts
-
Boolean isDedicated
defaults to false -
Boolean debug
defaults to false -
Boolean catchExceptions
defaults to false
function publish
publish()
alias of emit. see its signature.
function publishDelayed
publishDelayed()
alias of emitDelayed. see its signature.
function resetMediator
resetMediator()
erases any listener information (use with caution!)
function subscribe
subscribe(String|String[]
msgType, [Function
cbFn], [Object
subscriberOverride])
subscribes
Parameters:
msgType
can be a string (topic), space separated list of strings or array of strings (topics)
[cbFn]
if ommited, looks for 'onMsgType' and 'on' functions on the caller context|subscriberOverride, otherwise uses cbFn
[subscriberOverride]
useful when invoking from the Mediator singleton. function unsubscribe
unsubscribe(String|String[]
msgType, [Object
subscriberOverride])
Parameters:
msgType
can be a string (topic), space separated list of strings or array of strings (topics)
[subscriberOverride]
useful when invoking from the Mediator singleton.