import
Simply add state and/or reducers from other redux-components in one line.
Note: Currently only works when importing from other
redux-sands
-wrappers. A future release will allow to import any action and state.
redux-sands
also provides a clean and easy way to import other states and reducers.
reducer
import({ reducer: { [wrapperName]: ["reducerName", "reducerName"] }})
Import other plain reducers by first using the key reducer
, which holds an object of tuples containing the wrapper's name and an array of the reducer's names.
When importing reducers, you have to hook up the saga-export to the saga-middleware in your app. Else the action won't get fired.
If you don't have it installed yet, here's the project.
Importing a saga-reducer
When importing a reducer that uses saga, the import changes slightly. Instead of simply using a string to identify the reducer, an object has to be passed to the array containing the reducer-names as origin
as well as the bool withSaga
to true.
state
import({ state: { [wrapperName]: ["stateProp", "stateProp"] }})
Import oter state props. Works like importing other reducers.
Renaming
You're not limited to import them 'as-is'. Every reducer/state-prop can be renamed by simply replacing the string-definition with an object: { origin: "originalName", as: "customNameInThisWrapper" }
.
Last updated