0.0.5 • Published 4 years ago

@martini97/redux-log-slow-reducers v0.0.5

Weekly downloads
389
License
MIT
Repository
github
Last release
4 years ago

@martini79/redux-log-slow-reducers

license Build Status Coverage Status Maintainability

Warn about slow reducers in your Redux app.

Fork of redux-log-slow-reducers

Installation

npm install --save redux-log-slow-reducers
# or
yarn add @martini97/redux-log-slow-reducers

Usage

// Note: There is a optional second argument to logSlowReducers which allows you
//       to define how slow a reducer must be to trigger a warning (in ms) and
//       a predicate to decide whether or not to wrap the reducer functions. The
//       default value for threshold is 8ms, as this is half the time available
//       in one frame to run at 60fps. If you do not pass a predicate it will
//       always wrap the reducers.

import logSlowReducers from '@martini97/redux-log-slow-reducers';
import { createStore, combineReducers } from 'redux';

import * as reducers from './reducers';

const loggingReducers = logSlowReducers(
  reducers,
  { thresholdInMs: 10, predicate: () => process.env.NODE_ENV !== 'production' }
);
const store = createStore(combineReducers(loggingReducers));

Contributing

This project uses commitlint to enforce commit patterns, since it runs on CI there is no getting around that, so if you want to avoid having your CI breaking, consider adding this to your .git/hooks/commit-msg:

ROOT=$(git rev-parse --show-toplevel)
NODE_BIN="$ROOT/node_modules/.bin"
COMMITLINT="$NODE_BIN/commitlint"

sed '/^# Please enter the commit message for your changes/,$d' $1 | $COMMITLINT