Skip to content

omnidan/redux-ignore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-ignore

higher-order reducer to ignore redux actions

Installation

npm install --save redux-ignore

Ignoring actions

redux-ignore is a reducer enhancer (higher-order reducer), it provides the ignoreActions function, which takes an existing reducer and an array of actions to be ignored.

Firstly, import redux-ignore:

// Redux utility functions
import { combineReducers } from 'redux';
// redux-ignore higher-order reducer
import ignoreActions from 'redux-ignore';

Then, add ignoreActions to your reducer(s) like this:

combineReducers({
  counter: ignoreActions(counter, [INCREMENT_COUNTER])
})

Now you won't be able to increment the counter anymore, because the INCREMENT_COUNTER action is ignored.

What is this magic? How does it work?

Have a read of the Implementing Undo History recipe in the Redux documents, which explains in detail how higher-order reducers work.

License

MIT, see LICENSE.md for more information.

About

♻️ higher-order reducer to ignore redux actions

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published