Created
June 27, 2018 14:31
-
-
Save Nkzn/a8ac4796fc9060623f905ebb9c335d5b 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
import { doHoge, doFuga, addFoo, addBar } from "../ducks"; | |
class ApplicationService { | |
constructor(private dispatch: Dispatch, private client: ApiClient) { | |
} | |
async getHoge(id: number) { | |
const hoge = await this.client.fetchHoge(id); | |
this.dispatch(doHoge(hoge.id)); | |
const fuga = await this.client.fetchFuga(hoge.id); | |
this.dispatch(doFuga(fuga.id, hoge.name)); | |
} | |
getFoo() { | |
this.dispatch(async (dispatch, getState) => { | |
const {foo, bar} = getState(); | |
dispatch(addFoo(foo + 1)); | |
dispatch(addBar(bar + 1)); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment