ice-lab / icestore

🌲 Simple and friendly state for React
MIT License
397 stars 35 forks source link

Bug: TS reports 2 args needed instead of 1 when invoking a reducer from effect #115

Closed avalanche1 closed 4 years ago

avalanche1 commented 4 years ago

@ice/store version: 1.4.0

Steps To Reproduce

export const model = {
  state: 0,
  reducers: {
    foo(state: number, increment: number) {
      state += increment;
    },
  },
  effects: () => ({
    async asyncIncrement(increment: number) {
      model.reducers.foo(increment);
    },
  }),
};

image

alvinhui commented 4 years ago

in this case, using:

{
   effects: (dispatch) => ({
       async asyncIncrement(payload) {
          dispatch.foo(payload);
       }
   })
}
avalanche1 commented 4 years ago

Did you mean ?

{
   effects: (dispatch) => ({
       async asyncIncrement(payload) {
          dispatch.modelName.foo(payload);
       }
   })
}