subscribeToStateChanges()
Home > @gooddata/sdk-ui-dashboard > IDashboardEventHandling > subscribeToStateChanges
IDashboardEventHandling.subscribeToStateChanges() method
Subscribe to state changes of the dashboard.
Signature:
subscribeToStateChanges(callback: DashboardStateChangeCallback): IDashboardEventHandling;
Parameters
Parameter | Type | Description |
---|---|---|
callback | DashboardStateChangeCallback | 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 and useDashboardDispatch 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.