8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 实现 store.subscribe subscribe (subscriber, actionSubscriber) { const emitter = this.$emitter; const originViewInstance = getCurrentPages().pop() || {}; if (subscriber) { this.storeUpdateLisitenerDispose = emitter.addListener('updateState', ({ state, mutation, prevState }) => { const currentPageInstance = getCurrentPages().pop() || {}; const instanceView = originViewInstance.$viewId || -1; const currentView = currentPageInstance.$viewId || -1; // 已经不在当前页面的不再触发 if (instanceView === currentView) { subscriber(mutation, wrapState({ ...this.storeInstance.data }), wrapState({ ...prevState })); } }); } if (actionSubscriber) { this.storeDispatchActionLisitenerDispose = emitter.addListener('dispatchAction', (action, next) => { actionSubscriber(action, next); }); } };
如果这个方法 subscribe 调用2次了,那么在unload 生命周期里面 this.storeUpdateLisitenerDispose 只有一个被执行注销掉Listener
The text was updated successfully, but these errors were encountered:
No branches or pull requests
// 实现 store.subscribe
subscribe (subscriber, actionSubscriber) {
const emitter = this.$emitter;
const originViewInstance = getCurrentPages().pop() || {};
if (subscriber) {
this.storeUpdateLisitenerDispose = emitter.addListener('updateState', ({ state, mutation, prevState }) => {
const currentPageInstance = getCurrentPages().pop() || {};
const instanceView = originViewInstance.$viewId || -1;
const currentView = currentPageInstance.$viewId || -1;
// 已经不在当前页面的不再触发
if (instanceView === currentView) {
subscriber(mutation, wrapState({ ...this.storeInstance.data }), wrapState({ ...prevState }));
}
});
}
if (actionSubscriber) {
this.storeDispatchActionLisitenerDispose = emitter.addListener('dispatchAction', (action, next) => {
actionSubscriber(action, next);
});
}
};
如果这个方法 subscribe 调用2次了,那么在unload 生命周期里面 this.storeUpdateLisitenerDispose 只有一个被执行注销掉Listener
The text was updated successfully, but these errors were encountered: