redux-logger-filter
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Redux-logger-filter

Redux-logger-filter is a helper module to provide filter function to redux-logger.

You can configure Redux-logger to log only certain actions.

Install

npm i -D redux-logger-filter

Usage

Use the predicate parameter of the createLogger function.

import { applyMiddleware, createStore } from 'redux';
import { createLogger } from 'redux-logger';
import { makeLogFilter } from 'redux-logger-filter';
 
// Set to log only 'INCREASE' and 'DECREASE'.
const logger = createLogger({
  predicate: makeLogFilter('INCREASE', 'DECREASE'),
});
 
const store = createStore(reducer, applyMiddleware(logger));

Other Options

// You can pass it in array.
const filterList = ['counter/INCREASE', 'counter/DECREASE'];
 
const logger = createLogger({
  predicate: makeLogFilter(filterList)
});
 
// You can also put Action Creator directly.
import { increase, decrease } from './modules/counter.js';
 
const logger = createLogger({
  predicate: makeLogFilter(increase, decrease)
});
const logger = createLogger({
  predicate: makeLogFilter([increase, decrease])
});
 
// Action Objects
const logger = createLogger({
  predicate: makeLogFilter(increase(), decrease())
});
*/

excludeFilter

You can also exclude certain actions.

import { createLogger } from 'redux-logger';
import { makeLogFilter, excludeFilter } from 'redux-logger-filter';
 
const filter = makeLogFilter('INCREASE', 'DECREASE');
 
const logger = createLogger({
  predicate: excludeFilter(filter) // Excludes INCREASE and DECREASE actions.
});

Author

BitYounjgae (bityoungjae@gmail.com)

License

MIT

Package Sidebar

Install

npm i redux-logger-filter

Weekly Downloads

8

Version

2.0.2

License

MIT

Unpacked Size

8.75 kB

Total Files

8

Last publish

Collaborators

  • bityoungjae