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 #40

Closed

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.

@nifanic nifanic closed this Feb 17, 2020
@nifanic nifanic deleted the hotfix/33-generic-action branch February 17, 2020 02:14
@nifanic nifanic restored the hotfix/33-generic-action branch February 17, 2020 02:25
@nifanic nifanic deleted the hotfix/33-generic-action branch February 17, 2020 02:27
@nifanic nifanic restored the hotfix/33-generic-action branch February 17, 2020 02:29
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.

1 participant