Skip to content

Instantly share code, notes, and snippets.

@craigbeck
Created March 30, 2019 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigbeck/7653ff264753b14bd8f30e1e16e0bf05 to your computer and use it in GitHub Desktop.
Save craigbeck/7653ff264753b14bd8f30e1e16e0bf05 to your computer and use it in GitHub Desktop.
redux profile middleware
const profileMiddleware = _ => {
console.log('%cINSTALLED profileMiddleware', 'color:magenta');
return next => action => {
if (typeof action.then === 'function') {
return next(action);
}
// eslint-disable-next-line no-console
console.group('dispatch ' + action.type);
console.time(action.type);
const result = next(action);
// eslint-disable-next-line no-console
console.timeEnd(action.type);
console.log(action);
console.groupEnd('dispatch ' + action.type);
return next(result);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment