natur-service
危险
此插件现在已不推荐使用。跨模块通信功能已内置在 natur 的 watch API 中。
迁移到 watch
如果你正在使用 natur-service,请用模块定义中的 watch 选项替换:
// 之前 (natur-service)
class CountService extends NaturService<M, LM> {
constructor() {
super(store);
this.watch("count", (me: ModuleEvent) => {
console.log('count 模块已变更');
});
}
}
// 之后 (natur 内置 watch)
const count = {
state: {/* ... */},
actions: {/* ... */},
watch: {
count: (event: ModuleEvent, api: WatchAPI) => {
// 相同逻辑写在这里
},
},
};
跨模块的 action 分发,请使用 watch 回调中提供的 localDispatch API。
关联的 natur 版本
| natur | natur-service |
|---|---|
| 2.0.0 | 2.0.0 |
| 2.1.x | 2.1.x |
License
MIT