new Events()
Members
-
<static, constant> Events.ALL :string
-
The special catch all event type.
Type:
- string
Methods
-
mixin(obj)
-
Mixes in methods from this module's prototype to any object
in order to provide it with custom events.Parameters:
Name Type Description objObject Returns:
obj passed
- Type
- Object
-
off(name [, callback] [, context])
-
Remove one or many callbacks. If
contextis null, removes all callbacks
with that function. Ifcallbackis null, removes all callbacks for the event.
Ifnameis null, removes all bound callbacks for all events.Parameters:
Name Type Argument Description namestring | Array.<string> | Object String of space delimited events, array of event strings, or event map
callbackfunction | Object <optional>
May be function or context if passing event map
contextObject <optional>
Returns:
this object
- Type
- Object
-
on(name [, callback] [, context])
-
Bind one or more space separated events, or an events map,
to acallbackfunction. PassingALLwill bind the
callback to all events fired.Parameters:
Name Type Argument Description namestring | Array.<string> | Object String of space delimited events, array of event strings, or event map
callbackfunction | Object <optional>
May be function or context if passing event map
contextObject <optional>
Returns:
this object
- Type
- Object
-
once(name [, callback] [, context])
-
Bind events to only be triggered a single time. After the
first time the callback is invoked, it will be removed.Parameters:
Name Type Argument Description namestring | Array.<string> | Object String of space delimited events, array of event strings, or event map
callbackfunction | Object <optional>
May be function or context if passing event map
contextObject <optional>
Returns:
this object
- Type
- Object
-
trigger(name [, arg])
-
Trigger one event by name, firing all bound callbacks. Callbacks are
passed the same arguments astriggeris, apart from the event name
(unless you're listening onALL, which will cause your callback to
receive the true name of the event as the first argument).Parameters:
Name Type Argument Description namestring Single event name
arg* <optional>
<repeatable>
Returns:
this object
- Type
- Object