Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A User Timing middleware for redux to create performance markers for dispatched actions
const userTiming = () => (next) => (action) => {
if (performance.mark === undefined) return next(action);
performance.mark(`${action.type}_start`);
const result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`,
);
return result;
}
@Harrisonkamau

This comment has been minimized.

Copy link

@Harrisonkamau Harrisonkamau commented Feb 6, 2019

Nice one @vcarl!
I wrote a similar blog a while back:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment