Class: EventsDispatcher

StockChartX. EventsDispatcher


new EventsDispatcher()

Represent events dispatcher that manages events subscriptions.

Methods


fire(eventName, event)

Fires given event.
Parameters:
Name Type Description
eventName String The event name.
event Object The event object.
Example
obj.fire('click', {x: 10, y: 20});

off(eventNames, target)

Unsubscribes from event(s).
Parameters:
Name Type Argument Description
eventNames String The event names to unsubscribe.
target Object <optional>
The optional target to unsubscribe from events with a given target.
Example
// Unsubscribe from 'click' event
 obj.off('click');

 // Unsubscribe from 'click' event with 'my' namespace.
 obj.off('click.my');

 // Unsubscribe from 'click' and 'doubleclick' events.
 obj.off('click doubleclick');

 // Unsbuscribe from all events with a given target.
 obj.off(null, target);

on(eventNames, handler, target)

Subscribes to event(s).
Parameters:
Name Type Argument Description
eventNames String The event names to subscribe separated by space.
handler function The event handler.
target Object <optional>
The optional event target object (for internal use).
Example
// Subscribe to 'click' event.
 obj.on('click', function() {});

 // Subscribe to 'click' and 'doubleclick' events.
 obj.on('click doubleclick', function() {});

 // Subscribe to 'click' event with 'my' namespace.
 obj.on('click.my', function() {});

Type Definitions


EventHandler()

The callback to handle next animation frame.