easy-peasy
easy-peasy copied to clipboard
storeState argument on effectOn's stateResolvers is missing
According to docs, stateResolvers pass two arguments, so one can do something like this:
const store = createStore({
listener: {
onTodosChanged: unstable_effectOn([(_state, storeState) => storeState.todos], (actions) => {
actions.setFired(true);
}),
fired: false,
setFired: action((state, payload) => {
state.fired = payload;
}),
},
todos: [],
addTodo: action((state, payload) => {
state.todos.push(payload);
}),
});
Unfortunately, the following test fails:
expect(store.getState().listener.fired).toBe(false);
store.getActions().addTodo('add onEffect api');
expect(store.getState().listener.fired).toBe(true); // actual :false