cnap-cobre/synapse

View on GitHub
frontend/src/store/monitorReducerEnhancer.js

Summary

Maintainability
A
0 mins
Test Coverage
const round = number => (Math.round(number * 100) / 100);
 
const monitorReducerEnhancer = createStore => (
reducer,
initialState,
enhancer,
) => {
const monitoredReducer = (state, action) => {
const start = performance.now();
const newState = reducer(state, action);
const end = performance.now();
const diff = (round(end - start));
 
console.log('reducer process time:', diff);
 
return newState;
};
 
return createStore(monitoredReducer, initialState, enhancer);
};
 
export default monitorReducerEnhancer;