Last active
October 11, 2017 14:34
-
-
Save DScheglov/6d12397f08aef5e0da6d0fec60b35f78 to your computer and use it in GitHub Desktop.
async/await vs promise as monad
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 { api } from '../api'; | |
import { regUser } from './creators'; | |
export const loadProject = projectId => async dispatch => { | |
const user = await api.loadProject(projectId); | |
dispatch( | |
regUser(user) | |
); | |
}; |
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 { api } from '../api'; | |
import { regUser } from './creators'; | |
export const loadProject = projectId => dispatch => ( | |
api.loadProject(projectId) | |
.then(regUser) | |
.then(dispatch) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment