Returns the current callback count.
The current callback count.
Returns the current event count.
Returns the current event count.
Returns the current eventbus name.
The current eventbus name.
Just like on
, but causes the bound callback to fire several times up to the count specified before being
removed. When multiple events are passed in using the space separated syntax, the event
will fire count times for every event you passed in, not once for a combination of all events.
Number of times the function will fire before being removed.
Event name(s) or event map.
Event callback function or context for event map.
Optional
context: objectEvent context
Optional
options: EventOptionsOut | EventOptionsEvent registration options.
This Eventbus instance.
Returns an iterable for all stored events yielding an array with event name, callback function, and event context.
Optional
regex: RegExpOptional regular expression to filter event names.
Generator
Returns the options of an event name.
Event name(s) to verify.
The event options.
Returns whether an event name is guarded.
Event name(s) or event map to verify.
Optional
data: objectStores the output of which names are guarded.
Whether the given event name is guarded.
Returns an iterable for the event names / keys of registered event listeners along with event options.
Optional
regex: RegExpOptional regular expression to filter event names.
Generator
Tell an object to listen to a particular event on another object. The advantage of using this form, instead of other.on(event, callback, object), is that listenTo allows the object to keep track of the events, and they can be removed all at once later on. The callback will always be called with object as context.
This Eventbus instance.
view.listenTo(model, 'change', view.render);
Remove a previously-bound callback function from an object. If no context is specified, all the versions of the callback with different contexts will be removed. If no callback is specified, all callbacks for the event will be removed. If no event is specified, callbacks for all events will be removed.
Note that calling model.off(), for example, will indeed remove all events on the model.
This Eventbus instance.
// Removes just the `onChange` callback.
object.off('change', onChange);
// Removes all 'change' callbacks.
object.off('change');
// Removes the `onChange` callback for all events.
object.off(null, onChange);
// Removes all callbacks for `context` for all events.
object.off(null, null, context);
// Removes all callbacks on `object`.
object.off();
Bind a callback function to an object. The callback will be invoked whenever the event is fired. If you have a large number of different events on a page, the convention is to use colons to namespace them: 'poll:start', or 'change:selection'.
To supply a context value for this when the callback is invoked, pass the optional last argument:
model.on('change', this.render, this)
or model.on({change: this.render}, this)
.
Event name(s) or event map.
Event callback function or context for event map.
Optional
context: objectEvent context
Optional
options: EventOptionsOut | EventOptionsEvent registration options.
This Eventbus instance.
// The event string may also be a space-delimited list of several events...
book.on('change:title change:author', ...);
Callbacks bound to the special 'all' event will be triggered when any event occurs, and are passed the name of
the event as the first argument. For example, to proxy all events from one object to another:
proxy.on('all', (eventName) => {
object.trigger(eventName);
});
All event methods also support an event map syntax, as an alternative to positional arguments:
book.on({
'change:author': authorPane.update,
'change:title change:subtitle': titleView.update,
'destroy': bookView.remove
});
Just like on
, but causes the bound callback to fire only once before being removed. Handy for saying "the next
time that X happens, do this". When multiple events are passed in using the space separated syntax, the event
will fire once for every event you passed in, not once for a combination of all events
Event name(s) or event map.
Event callback function or context for event map.
Optional
context: objectEvent context.
Optional
options: EventOptionsOut | EventOptionsEvent registration options.
This Eventbus instance.
Tell an object to stop listening to events. Either call stopListening with no arguments to have the object remove all of its registered callbacks ... or be more precise by telling it to remove just the events it's listening to on a specific object, or a specific event, or just a specific callback.
Event context
Optional
name: stringEvent name(s)
Optional
callback: FunctionEvent callback function
This Eventbus instance.
view.stopListening();
view.stopListening(model);
Trigger callbacks for the given event, or space-delimited list of events. Subsequent arguments to trigger will be passed along to the event callbacks.
Event name(s)
Rest
...args: any[]Additional arguments passed to the event function(s).
This Eventbus instance.
Provides trigger
functionality, but collects any returned Promises from invoked targets and returns a
single Promise generated by Promise.resolve
for a single value or Promise.all
for multiple results. This is
a very useful mechanism to invoke asynchronous operations over an eventbus.
Event name(s)
Rest
...args: any[]Additional arguments passed to the event function(s).
A Promise with any results.
Provides trigger
functionality, but collects any returned result or results from invoked targets as a single
value or in an array and passes it back to the callee in a synchronous manner.
Event name(s).
Rest
...args: any[]Additional arguments passed to the event function(s).
The results of the event invocation.
Provides the ability to bind and trigger custom named events. Bound callback functions may be triggered asynchronously or synchronously returning results.