Methods
combineReducers()
Wrapper around vanilla combineReducers() from redux package.
Adds support for Controller class instances in place of regular reducer
functions. Each instance encountered is replaced with the result of
Controller.reducer() call. The instance is then saved under controllers
key of the returned function. controllers is passed up the chain and
is intended to be used by the createStore().
- Source:
Container(WrappedComponent, …mappings)
Connects a React component to a Redux store. Additionally to regular connect() method
Container supports an extensive mapping functionality designed to work nice with
Controllers.
Container is capable of mapping any part of a Redux state tree to the props of the wrapped component. When mapping parts of the tree managed by controllers, Container calls Controller.$ method to select the data, thus calling any selector methods defined on the Controller level.
If mapping the path exactly equal to Controller.mountPathString, dispatch functions are also mapped by default.
The list of mapping options:
| Mapping | Description | Result |
|---|---|---|
"path.*" |
Map all sub-keys at path to props. |
path.key1 to props.key1path.key2 to props.key2 ... |
{ "path": "*" } |
Same as "path.*" |
|
"path.key" |
Map the path to the prop that equal to the last key in the path. | path.key to props.key |
{ "path.key": "remapKey" } |
Map the path to the prop that is explicitly specified. | path.key to props.remapKey |
"path.dispatch*" |
Only map dispatch functions of the controller to props. | path.dispatchFunc1 to props.func1path.dispatchFunc2 to props.func2 ... |
{ "path.dispatch*": "*" } |
Same as "path.dispatch*" |
|
{ "path.dispatch*": "funcs"} |
Map all dispatch functions of the controller to the specified prop. | path.dispatchFunc1 to props.funcs.func1auth.dispatchFunc2 to props.funcs.func2 ... |
"path.select*" |
Only map state managed by the controller to props (no dispatches). | |
"path.$" |
Same as "path.select*" |
|
{ "path.select*": "*" } |
Same as "path.select*" |
|
{ "path.select*": "keys" } |
Only map state managed by the controller to props (no dispatches). | path.key1 to props.keys.key1 path.key2 to props.keys.key2 ... |
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
WrappedComponent |
React.Component
|
Component to connect. |
|
mappings |
string
|
Object.<string, string>
|
<repeatable> |
Any amount of mappings that should be applied when connecting Redux store to the component. |
createStore()
Wrapper around vanilla createStore() from redux package. Creates the
regular Redux store and extends it with getController() function.
- Source: