Created
May 9, 2018 13:12
-
-
Save caasi/a28b35c210591d9ff8a68d791469c493 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 Dispatch = any; | |
type Action<T> = (dispatch: Dispatch) => Promise<T>; | |
const actionA: (string) => Action<string> = | |
(foo) => async (dispatch) => { | |
dispatch('tell redux to do something'); | |
return 'foo'; | |
} | |
const actionB: (string) => Action<number> = | |
(bar) => async (dispatch) => { | |
dispatch('tell redux to do something else'); | |
return 42; | |
} | |
const actionC: (string) => Action<number> = | |
(baz) => async (dispatch) => { | |
const resultA = await actionA(baz)(dispatch); | |
dispatch('foo'); | |
const resultB = await actionB(resultA)(dispatch); | |
dispatch('bar'); | |
return resultB; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment