Skip to content

forstaathletics/redux-delegate-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-delegate-action

Delegate an action to be dispatched at the end of the current reducers execution.

Sometimes you'd like to dispatch an action within the execution of a reducer. But you should not do this and may be explicitly forbidden by Redux in the future. But, what can be done is an action can be created, saved and disptached later at the appropriate time.

This module must be initialized with the store before use. You only need to initialize it once:

import { init as delegateInit } from 'redux-delegate-action'
import makeStore, { addReducer, addMiddleware } from './store'

const store = makeStore()

// Initialize the delegator
delegateInit(store)

Using the delegate is very simple. Just call delegate() with an action:

import delegate from 'redux-delegate-action'

myReducer = (state, action) => {
  // Do some stuff
  // ...
  // delegate an action to be dispatched after the reducers are done
  delegate(actionCreater(params))
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published