Created
April 25, 2022 06:14
-
-
Save alegoritma/042e731e1f3870e9c1956bd3d1c125f4 to your computer and use it in GitHub Desktop.
With this middleware you can measure timings on performance tab in the browser's devTools
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 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; | |
| } | |
| const store = configureStore({ | |
| reducer: rootReducer, | |
| devTools: true, | |
| middleware: (getDefaultMiddleware) => [...getDefaultMiddleware(), userTiming] | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment