id-redux-modules
Groups your Redux reducers and routes into modules so you can easily compose them.
Installation
npm install --save id-redux-modules
Usage
const Module = require('id-redux-modules').Module
const myModule = new Module({
name: "MyModule",
store: myStore,
})
Module
Represents a composable collection of redux parts.
Kind: global class
- Module
- new Module(options)
- .name ⇒
String - .name ⇒
Undefined - .store ⇒
String - .store ⇒
Undefined - .actions ⇒
Object - .actions ⇒
undefined - .actionCreators ⇒
Object - .actionCreators ⇒
Undefined - .components ⇒
Object - .components ⇒
Undefined - .routes ⇒
Object - .routes ⇒
Undefined - .reducers ⇒
Object - .reducers ⇒
Undefined - .submodules ⇒
Array - .submodules ⇒
Undefined - .addAction(name) ⇒
undefined - .removeAction(name) ⇒
undefined - .addActionCreator(name, actionCreator) ⇒
undefined - .removeActionCreator(name) ⇒
Undefined - .addReducer(name, reducer) ⇒
Undefined - .removeReducer(name) ⇒
Undefined - .addSubmodule(options) ⇒
Undefined - .removeSubmodule(submodule) ⇒
Undefined
new Module(options)
Represents a composable collection of redux parts.
| Param | Type | Description |
|---|---|---|
| options | Object |
The options object. |
| options.name | String |
The name of the module. |
| options.store | Object |
The Redux store instance. |
| options.actions | Object |
The Redux actions the module can dispatch. |
| options.actionCreators | Object |
The action creators for the actions. |
| options.components | Object |
The components the module uses. |
| options.routes | function |
The final route component returned from the module. |
| options.reducers | Object |
The reducers of the module. They process the module's actions. |
| options.submodules | Object |
An array of submodules. |
module.name ⇒ String
Returns the name of the module.
Kind: instance property of Module
Returns: String - name - The name of the module
module.name ⇒ Undefined
Sets the name of the module.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the module. |
module.store ⇒ String
Returns the store of the module.
Kind: instance property of Module
Returns: String - store - The store of the module
module.store ⇒ Undefined
Sets the store of the module and all it's submodules.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| store | Object |
The store. |
module.actions ⇒ Object
Returns the actions of the module.
Kind: instance property of Module
Returns: Object - actions
module.actions ⇒ undefined
Replaces the actions.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| actions | Object |
The new actions. |
module.actionCreators ⇒ Object
Returns the actionCreators of the module.
Kind: instance property of Module
Returns: Object - actionCreators
module.actionCreators ⇒ Undefined
Replaces the actionCreators.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| actionCreators | Object |
The new actionCreators. |
module.components ⇒ Object
Returns the components of the module.
Kind: instance property of Module
Returns: Object - components
module.components ⇒ Undefined
Replaces the components.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| components | Object |
The new components. |
module.routes ⇒ Object
Calls the modules' routes function and composes it with the routes of the submodules, creating one route tree.
Kind: instance property of Module
Returns: Object - Routes
module.routes ⇒ Undefined
Replaces the routes.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| routes | function |
The routes function. Returns a React Element. |
module.reducers ⇒ Object
Returns the reducers of the module combined with the reducers of the submodules.
Kind: instance property of Module
Returns: Object - actions
module.reducers ⇒ Undefined
Replaces the reducers.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| reducers | Object |
The new reducers. |
module.submodules ⇒ Array
Returns the submodules of the module.
Kind: instance property of Module
Returns: Array - submodules
module.submodules ⇒ Undefined
Replaces the submodules.
Kind: instance property of Module
| Param | Type | Description |
|---|---|---|
| submodules | Array |
The new submodules. |
module.addAction(name) ⇒ undefined
Adds an action to the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the action. |
module.removeAction(name) ⇒ undefined
Removes an action from the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the action. |
module.addActionCreator(name, actionCreator) ⇒ undefined
Adds an actionCreator to the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the actionCreator. |
| actionCreator | function |
The actionCreator function. |
module.removeActionCreator(name) ⇒ Undefined
Removes an actionCreator from the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the actionCreator. |
module.addReducer(name, reducer) ⇒ Undefined
Adds a reducer to the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the reducer. |
| reducer | function |
The reducer function. |
module.removeReducer(name) ⇒ Undefined
Removes a reducer from the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the reducer. |
module.addSubmodule(options) ⇒ Undefined
Adds a submodule to the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| options | Object |
The options for the submodule. |
module.removeSubmodule(submodule) ⇒ Undefined
Removes a submodule from the module.
Kind: instance method of Module
| Param | Type | Description |
|---|---|---|
| submodule | Object |
The options for the submodule. |