• Stars
    star
    843
  • Rank 54,052 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

♻️ higher-order reducer to ignore redux actions

redux-ignore

NPM version (>=1.2) Build Status Dependencies js-standard-style https://paypal.me/DanielBugl/10 https://gratipay.com/~omnidan/

higher-order reducer to ignore redux actions

can be used to avoid performance problems in large apps by skipping reducer subtrees

Installation

npm install --save redux-ignore

API

import { ignoreActions, filterActions } from 'redux-ignore';

ignoreActions(reducer, [ARRAY_OF_ACTIONS])
ignoreActions(reducer, (action) => !action.valid)

filterActions(reducer, [ARRAY_OF_ACTIONS])
filterActions(reducer, (action) => action.valid)

Ignoring Actions

redux-ignore is a reducer enhancer (higher-order reducer), it provides the ignoreActions function, which takes an existing reducer and either:

  • An array of actions to be ignored, or...
  • A predicate function for filtering out actions.

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.

Alternatively, you can ignore actions via a predicate function:

combineReducers({
  counter: ignoreActions(counter, (action) => action.type === INCREMENT_COUNTER)
});

Filtering Actions

You can also use filterActions to only accept actions that are declared in an array, or that satisfy the predicate function:

import { combineReducers } from 'redux';
import { filterActions } from 'redux-ignore'; // pull in the filterActions function
import { STAY_COOL, KEEP_CHILLIN } from './actions';
import { counter, notACounter } from './reducers';

combineReducers({
  counter: filterActions(counter, (action) => action.type.match(/COUNTER$/)), // only run on actions that satisfy the regex
  notACounter: filterActions(notACounter, [STAY_COOL, KEEP_CHILLIN]) // only run for these specific relaxing actions
});

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.

More Repositories

1

redux-undo

♻️ higher order reducer to add undo/redo functionality to redux state containers
JavaScript
2,907
star
2

node-emoji

πŸ’– simple emoji support for node.js projects
TypeScript
1,307
star
3

redux-recycle

♻️ higher-order reducer to reset the redux state on certain actions
JavaScript
147
star
4

redux-undo-boilerplate

♻️ πŸ”§ a magical boilerplate with hot reloading and awesome error handlingβ„’
JavaScript
121
star
5

ArduinoPure

πŸ“Ό This is a project to achieve compiling programs for the Arduino without any external programs like the Arduino IDE. It uses all the standard programs you love so much: make, cc, ... This is also the only way I was able to flash arduino programs to microcontrollers with the stk500.
C++
14
star
6

asv

⭐ Electron / Atom Shell Version Management à la "n" and "m"
Shell
9
star
7

git-leaf

πŸƒ simple and beautiful git trees
JavaScript
8
star
8

python-latex

πŸŽ“ Python modules for LaTeX parsing and management
Python
7
star
9

node-np

🎡 standalone last.fm bot written in node.js
JavaScript
7
star
10

node-kaomoji

( Ν‘Β° ΝœΚ– Ν‘Β°) simple kaomoji support for node.js projects
HTML
6
star
11

statsbot

(telegram) message stats bot
JavaScript
5
star
12

iForceBot

[DISCONTINUED] If you want to work on it, feel free to fork and start working. An IRC bot with much power and easy-to-code modules! Daniel0108 only maintains the framework and *his* plugins. The plugin downloader and repository are not official, nor maintained by him.
Python
4
star
13

ZenHubPlus

Userstyle to make ZenHub features look more integrated on GitHub
CSS
3
star
14

log-simple

πŸ’¬ Super Simple JavaScript Logging
JavaScript
3
star
15

now

✨ simple real-time reddit/HN-inspired social network crafted with React and Meteor
JavaScript
3
star
16

karma

manage activities with a points/karma system
JavaScript
3
star
17

coffeedonate

β˜• donate a cup of coffee, because coffee == <3
JavaScript
3
star
18

tuio-to-tlay

Converting TUIO to TLay Touch events
C++
2
star
19

PyTerm

πŸ’» Yet-another simple Python Terminal simulator made to practise curses in python.
Python
2
star
20

omnidan.github.io

🌐 my website
HTML
2
star
21

tlay-touch

TLay Touch is a UDP protocol that allows you to add multitouch support to programs.
C++
2
star
22

scipy-notebook-0.18

scipy-notebook with scikit-learn 0.18
1
star
23

Arrbus

🚌 Communication with the BusPirate v3
JavaScript
1
star
24

meilog

πŸ“ƒ beautiful logging library with support for structured logs (for cloud services) and local logging with colors
JavaScript
1
star
25

tn2_manager

The manager system for the new TouchNet 2.X
C++
1
star
26

tn2_core

The core system for the new TouchNet 2.X
C++
1
star
27

dotfiles-old

πŸ’Ύ My dotfiles, mostly used to share my configuration on all my machines, but of course you can also use them.
Vim Script
1
star
28

omnidan-net

omnidan.net website
HTML
1
star
29

reddit-roulette

πŸŽͺ Chrome extension: Easily get to a random subreddit by clicking a button. Wasting time has never been so easy.
JavaScript
1
star
30

sync

TouchLay Sync - Real-time document-based data syncronisation service in NodeJS using socket.io and MongoDB.
JavaScript
1
star
31

BRUTE.PY

πŸ”§ [DISCONTINUED] If you want to work on it, feel free to fork and start working. Simple python bruteforcing script for educational and testing purposes.
Python
1
star
32

Shift

simple shift-based time scheduling for busy people
CSS
1
star