easy-peasy icon indicating copy to clipboard operation
easy-peasy copied to clipboard

storeState argument on effectOn's stateResolvers is missing

Open methyl opened this issue 5 years ago • 0 comments

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

methyl avatar Nov 09 '20 17:11 methyl