Skip to content

Instantly share code, notes, and snippets.

@dereknelson
Created April 26, 2019 00:39
Show Gist options
  • Save dereknelson/6e5d98b7015c149afdecc4a2eca7bdf8 to your computer and use it in GitHub Desktop.
Save dereknelson/6e5d98b7015c149afdecc4a2eca7bdf8 to your computer and use it in GitHub Desktop.

Revisions

  1. dereknelson created this gist Apr 26, 2019.
    14 changes: 14 additions & 0 deletions store.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    //...store logic

    // profiler for redux actions
    const userTiming = (store) => (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
    }
    // add to middleware
    let middleware = [thunk]
    if (__DEV__) middleware.push(userTiming)