Created
June 6, 2019 04:33
-
-
Save koba04/78dad5c6b755a795240cba21d680f256 to your computer and use it in GitHub Desktop.
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
import { Dispatch } from 'redux' | |
export type Dispatch = Dispatch | |
export const createUseCase = <T>(name: string, usecase: () => Promise<any>) => async () => { | |
if (process.env.NODE_ENV === 'development') { | |
console.groupCollapsed(`%c[UseCase]%c ${name}`, 'color: #00c4cc', '') | |
console.time(name) | |
performance.mark(`start:${name}`) | |
} | |
await usecase() | |
if (process.env.NODE_ENV === 'development') { | |
console.timeEnd(name) | |
console.groupEnd() | |
performance.mark(`end:${name}`) | |
performance.measure(`[UseCase] ${name}`, `start:${name}`, `end:${name}`) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment