IDashboardEventHandling
Defines a facade that you can use to register or unregister dashboard event handlers.
export interface IDashboardEventHandling
Methods
Method | Description |
|---|---|
Adds a custom event handler. This is a lower-level API where the handler can include both the function to evaluate events and the function to trigger when the evaluation succeeds. | |
Adds a handler for particular event type. | |
Removes custom event handler. | |
Removes a handler for particular event type. This is reverse operation to IDashboardEventHandling.addEventHandler(). | |
Subscribe to state changes of the dashboard. | |
Unsubscribe from receiving calls about state changes of the dashboard. |
Method details
IDashboardEventHandling.addCustomEventHandler()method
Adds a custom event handler. This is a lower-level API where the handler can include both the function to evaluate events and the function to trigger when the evaluation succeeds.
addCustomEventHandler(handler: DashboardEventHandler): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
|---|---|---|
handler | event handler to add |
Returns
self, for call chaining sakes
Remarks
Attempts to register same handler twice will be ignored.
IDashboardEventHandling.addEventHandler()method
Adds a handler for particular event type.
addEventHandler<TEvents extends DashboardEvents | ICustomDashboardEvent>(eventType: string, callback: DashboardEventHandlerFn<TEvents>): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
|---|---|---|
eventType | string | type of the event to handle; this can be either built-event event type (see DashboardEventType), a custom event type or |
callback | DashboardEventHandlerFn<TEvents> | function to call when the event occurs |
Returns
Remarks
Every time event of that type occurs, the provided callback function will be triggered.
IDashboardEventHandling.removeCustomEventHandler()method
Removes custom event handler.
removeCustomEventHandler(handler: DashboardEventHandler): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
|---|---|---|
handler | event handler to remove |
Returns
self, for call chaining sakes
Remarks
In order for successful removal the entire handler object must be exactly the same as the one that was used when you added the handler.
IDashboardEventHandling.removeEventHandler()method
Removes a handler for particular event type. This is reverse operation to IDashboardEventHandling.addEventHandler().
removeEventHandler<TEvents extends DashboardEvents | ICustomDashboardEvent>(eventType: string, callback: DashboardEventHandlerFn<TEvents>): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
|---|---|---|
eventType | string | type of the event to stop handling; this can be either built-event event type (see DashboardEventType), a custom event type or |
callback | DashboardEventHandlerFn<TEvents> | originally registered callback function |
Returns
self, for call chaining sakes
Remarks
In order for this method to remove a handler, the arguments must be the same when you added the handler.
E.g. it is not possible to add a handler for all events using '*' and then subtract just one particular event from handling.
IDashboardEventHandling.subscribeToStateChanges()method
Subscribe to state changes of the dashboard.
subscribeToStateChanges(callback: DashboardStateChangeCallback): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
|---|---|---|
callback | function to call when dashboard state changes; the function will be called with two parameters: the new state and an instance of dispatch to use. |
Returns
self, for call chaining sakes
Remarks
There is no need to use this if all you need is your custom React components to get up-to-date state. Your React component code can (and really should) use the useDashboardSelector anduseDashboardDispatch() hooks instead.
Subscription to state changes is only really needed if you have custom code outside of React components and you need to extract custom data from state using the selectors API.
See also SingleDashboardStoreAccessor and DashboardStoreAccessorRepository for utility classes that make managing the callback subscriptions more convenient.
IDashboardEventHandling.unsubscribeFromStateChanges()method
Unsubscribe from receiving calls about state changes of the dashboard.
unsubscribeFromStateChanges(callback: DashboardStateChangeCallback): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
|---|---|---|
callback | callback that was previously used for subscription |
Returns
self, for call chaining sakes