new MessageDispatcher()
Dispatches messages by callback function if they match the
correspondent regular expression.
- Source:
Methods
-
add(regex, callback)
-
Adds callback for a message that returns
true
in the test of the regular expression.Parameters:
Name Type Description regex
RegExp Regular expression to match. callback
function Function to be called when the message matches the regular expression. - Source:
-
dispatch(message, param)
-
Dispatches the callbacks associated with the regular expressions matching the message.
Parameters:
Name Type Argument Description message
string Message to be dispatched. param
Object <optional>
Additional arguments to be passed through. - Source:
-
remove(regex)
-
Removes a callback.
Parameters:
Name Type Description regex
RegExp Regular expression associated with the callback to remove. - Source: