pauldijou / redux-act

An opinionated lib to create actions and reducers for Redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reusing Reducers and Actions

screenpunch opened this issue · comments

Hi,

Is it supported, and is there an example of reducer and action reuse with redux-act?

For example, if I defined counterReducer twice in combineReducers.

combineReducers({
counter1: counterReducer,
counter2: counterReducer
})

Is it possible to dispatch an action to target a specific reducer without duplicating action creators and reducers?

It is supported, it's just a normal reducer.

I don't think Redux allow to dispatch to a specific reducer, it's always to the store. So, just like you would need 2 different action types in normal Redux, you will need two different action creators with redux-act.

You might want to use a function to generate both the reducer and its actions rather than reusing the exact same reducer.

Thanks, wrapping everything in a higher order functions works very well