redux-user-timing
v1.0.2
Published
User Timing middleware for Redux
Downloads
2,997
Maintainers
Readme
redux-user-timing
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.
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