useAdaptableStateSubscribe hook
This hook allows you to subscribe to state changes.
For retrieving the state, use useAdaptableState.
Listening to view change event
import { useAdaptableStateSubscribe } from '@adaptabletools/adaptable-infinite-react';
function CustomCmp() {
useAdaptableStateSubscribe({
selector: (state) => state.view.currentViewId,
callback: (viewId, oldViewId) => {
console.log('view changed', viewId);
},
});
return <div>...</div>;
}The hook should be called with an object that expects the following properties
selector-(state: AdaptableState) => any- this function is called with the current Adaptable state and should return the part of the state that you're interested in.callback-(value, oldValue) => void- this function is called whenever the value returned by theselectorfunction changes. It's called with the new value and the old value.