natur-service
danger
This plugin is no longer recommended for use. The cross-module communication functionality has been built into natur itself via the watch API.
Migration to watch
If you were using natur-service, replace it with the watch option in your module definition:
// Before (natur-service)
class CountService extends NaturService<M, LM> {
constructor() {
super(store);
this.watch("count", (me: ModuleEvent) => {
console.log('count module has changed.');
});
}
}
// After (natur built-in watch)
const count = {
state: {/* ... */},
actions: {/* ... */},
watch: {
count: (event: ModuleEvent, api: WatchAPI) => {
// same logic here
},
},
};
For dispatching actions across modules, use the localDispatch API provided in the watch callback.