Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix #33 generic action #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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