Created
August 6, 2020 22:06
-
-
Save solomon-gumball/055319237bc3f85c88233fabeac4c86a to your computer and use it in GitHub Desktop.
This file contains 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
type ThunkAction<T> = (dispatch: Dispatch<T>) => T | |
type AsyncDispatch<T> = Dispatch<T | ThunkAction<T>> | |
function wrapAsync<T>(dispatch: Dispatch<T>): AsyncDispatch<T> { | |
return function(action: T | ThunkAction) { | |
if (action instanceof Function) { | |
return action(dispatch) | |
} | |
return dispatch(action) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment