You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const store = createStore(reducers.todos);
const listenerA = expect.createSpy(() => {});
const listenerB = expect.createSpy(() => {});
let unsubscribeA = store.subscribe(listenerA);
store.subscribe(listenerB);
unsubscribeA();
unsubscribeA();//invoke two times
store.dispatch(unknownAction());
expect(listenerA.calls.length).toBe(0);
expect(listenerB.calls.length).toBe(1); // failed
reason:
arr.splice(-1,1) still remove the item of the arr.
//createStore.js
function subscribe(listener) {
listeners.push(listener);
return function unsubscribe() {
var index = listeners.indexOf(listener);
// if index ===1 ,should return
listeners.splice(index, 1);
};
}
The text was updated successfully, but these errors were encountered:
jzlxiaohei
changed the title
Call unsubscribe many time will remove other listeners
Call unsubscribe many times will remove other listeners
Oct 23, 2015
I write a test
reason:
arr.splice(-1,1)
still remove the item of the arr.//createStore.js
}
The text was updated successfully, but these errors were encountered: