React bindings for redux-dynostore to provide dynamic redux features when a component is mounted.
import dynamic from '@redux-dynostore/react-redux'
export default dynamic('identifier', somethingDynamic(), somethingElseDynamic('with parameters'))(MyComponent)
The 'identifier'
shown above is the key that will be used for all instances of the component. If multiple instances are required to not share dynamic features (i.e. redux reducers), the the createInstance
function can be used:
import MyComponent from './MyComponent'
const MyComponent1 = MyComponent.createInstance('instance1')
const MyComponent2 = MyComponent.createInstance('instance2')
Enhancers are used to provide additional wrappers around the passed component when it is mounted. The following enhancers are provided:
- Reducers - dynamically attach reducers
- Sagas - dynamically run sagas
- Dispatch Action - dispatch actions when the component is mounted
- Subspaced - mounts the component is in a subspace for the components identifier
- Namespaced Reducers - dynamically attach reducers that are namespaced with the component's identifier
- Subspaced Sagas - dynamically run sagas that are subspaced for the component's identifier
- Dispatch Namepsaced Action - dispatch actions when the component is mounted that are namespaced with the component's identifier
Enahncers can be created for many use cases by implementing the following interface:
const enhancer = identifier => store => Component => EnhancedComponent
Additional enhancers can be injected on a specific instance of a dynamic component
const MyComponent1 = MyComponent.createInstance('instance1', subspaced())