Skip to content

Latest commit

 

History

History
 
 

redux-dynostore-react-redux

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@redux-dynostore/react-redux

build status npm version npm downloads License: BSD

React bindings for redux-dynostore to provide dynamic redux features when a component is mounted.

Usage

import dynamic from '@redux-dynostore/react-redux'

export default dynamic('identifier', somethingDynamic(), somethingElseDynamic('with parameters'))(MyComponent)

Multiple Instances

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

Enhancers are used to provide additional wrappers around the passed component when it is mounted. The following enhancers are provided:

  1. Reducers - dynamically attach reducers
  2. Sagas - dynamically run sagas
  3. Dispatch Action - dispatch actions when the component is mounted
  4. Subspaced - mounts the component is in a subspace for the components identifier
    1. Namespaced Reducers - dynamically attach reducers that are namespaced with the component's identifier
    2. Subspaced Sagas - dynamically run sagas that are subspaced for the component's identifier
    3. Dispatch Namepsaced Action - dispatch actions when the component is mounted that are namespaced with the component's identifier

Custom Enhancers

Enahncers can be created for many use cases by implementing the following interface:

const enhancer = identifier => store => Component => EnhancedComponent

Instance Enhancers

Additional enhancers can be injected on a specific instance of a dynamic component

const MyComponent1 = MyComponent.createInstance('instance1', subspaced())