Created
January 13, 2016 17:32
-
-
Save andy-polhill/a9a256b7e09bb77f2a00 to your computer and use it in GitHub Desktop.
React Perf Redux Middleware sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const whitelist = ['SEARCH_CHANGE_TEXT']; | |
const perfMiddleware = () => next => action => { | |
let result; | |
if (whitelist.includes(action.type)) { | |
console.group(action.type); | |
Perf.start(); | |
result = next(action); | |
Perf.stop(); | |
Perf.printWasted(Perf.getLastMeasurements()); | |
console.groupEnd(); | |
} else { | |
result = next(action); | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment