We would like the ability to pass in certain callback functions when stores are created that would track:
- Store initialisation
- Store changes
const onStoreInit = (storeInstance) => {
// do something when store initialises
};
const onStoreUpdate = (storeInstance, actionDispatched) => {
// do something when store updates
};
export const store = createStore({
...
name: 'my-store',
onStoreInit,
onStoreUpdate,
});
This would allow us to implement custom logic into our stores changing without having to mount many useEffects to track and respond to these changes.