raininfall.redux-perf-middleware
Version:
Measure the time that actions needs to change the state
28 lines (24 loc) • 809 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Redux performance logger
*
* @author Avraam Mavridis <avr.mav@gmail.com>
*
*/
var present = require('present');
var perflogger = exports.perflogger = function perflogger(store) {
return function (next) {
return function (action) {
var start = present();
console.log('%c Dispatching type "' + String(action.type) + '" start ' + start.toFixed(2) + ' ms.', 'background: #222; color: #bada55');
var result = next(action);
var end = present();
console.log('%c Action with type "' + String(action.type) + '" end ' + end.toFixed(2) + ' ms, took ' + (end - start).toFixed(2) + ' ms', 'background: #bada55; color: #222');
return result;
};
};
};
exports.default = perflogger;