Skip to content

Conversation

@nifanic
Copy link

@nifanic nifanic commented Feb 17, 2020

Fix for #33 generalizes Action type.

To specify custom action type:

  1. Create new NewAction type with desired shape by extending provided Action type and passing in new NEW_TYPE_NAME type:

    interface NewAction extends Action<NEW_TYPE_NAME> {
      payload: any;
    }
  2. Use reduce-reducers as before, but pass in NewAction, second type parameter:

    import reduceReducers from 'reduce-reducers';
    
    const initialState = { A: 0, B: 0 };
    
    const rootReducer = reduceReducers<NewState, NewAction>(
      initialState,
      addReducer,
      multReducer
    );

Your rootReducer is ready.

@joshweir
Copy link

+1 This should be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants