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

The current type structure does not support multiple action types for a sub-reducer in combineReducers #1

Open
headjoe3 opened this issue Jan 22, 2019 · 0 comments

Comments

@headjoe3
Copy link

I have a "Currency" reducer that is constructed with a table of action handlers
image

The problem is that there are different types of actions that can be dispatched which affect currency. So I have to type them in the action handler itself in order to disambiguate the action type that is being handled. In this example, an "AddCurrencyAction" stores a "Delta" value to be added to the currency, whereas a "SetCurrencyAction" stores a "Currency" value to overwrite the currency.
image

This is not allowed however, because createReducer wants all actions handlers to handle the same type of action.
image

My solution was to overload createReducer to generalize an action to an "any" type, with the assumption that I will be specifying the action type myself.
image

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

No branches or pull requests

1 participant