redux-user-timing

1.0.2 • Public • Published

redux-user-timing npm version Coverage Status CircleCI

User Timing middleware for profiling redux application

Introduction

Measuring performance is crucial for optimizing the application. Using with User Timing API, You can inspect performance about each dispatched redux action. For more details, check out Carl Vitullo's Blog: Performance Profiling a Redux App.

Performance Analysis Example in Chrome DevTools

Installation

$ npm i redux-user-timing

Alternatively, using yarn:

$ yarn add redux-user-timing

Then enable redux-user-timing with applyMiddleware()

import { createStore, applyMiddleware } from 'redux';
import userTiming from 'redux-user-timing';
import rootReducer from './reducers';
 
const store = createStore(rootReducer, applyMiddleware(userTiming));

Please, use this middleware only for development environment.

  • configureStore.js
import { createStore, applyMiddleware } from 'redux';
import userTiming from 'redux-user-timing';
import rootReducer from './reducers';
 
const configureStore = initialState => {
  const middlewares = [
    /* Some other middlewares */
  ];
 
  if (process.env.NODE_ENV !== 'production') {
    // Recommend to add redux-user-timing as a last middleware.
    middlewares.push(userTiming);
  }
 
  const store = createStore(
    rootReducer,
    initialState,
    applyMiddleware(...middlewares),
  );
 
  return store;
};
 
export default configureStore;

Thanks

This idea is inspired by clarkbw. and thanks for Carl Vitullo about kind blog explanation.

License

MIT © Taehwan Noh

Package Sidebar

Install

npm i redux-user-timing

Weekly Downloads

698

Version

1.0.2

License

MIT

Unpacked Size

11.1 kB

Total Files

11

Last publish

Collaborators

  • taehwanno