A Hub is an event manager. It allows to register event handler and to trigger events.
There are three hubs on the viewer:
- The state hub, available on
- The local context hub, available on
- The global context hub, available on
The interface of a hub is the following:
| ||A method that register an handler on the event name. When the event is emitted on the hub, the callback function is executed with the event payload as first argument. The |
| ||This method is the same as the |
| ||Cancel the corresponding subscription.|
| ||Emit an event with a optional payload.|
| ||Remove all subscriptions of this hub.|
The third parameter
options is an optional
Object that accepts the property
getLastEvent as a boolean default to
true, the callback is trigered with the last event (if it exists) immediately. It can be interesting for state synchronization.
Many of the events you may use are State events. Find more reading the State reference.
Other usefull events are from the global and the local context. Find more reading the $viewer reference.