Skip to content

Instantly share code, notes, and snippets.

@DScheglov
Last active October 11, 2017 14:34
Show Gist options
  • Save DScheglov/6d12397f08aef5e0da6d0fec60b35f78 to your computer and use it in GitHub Desktop.
Save DScheglov/6d12397f08aef5e0da6d0fec60b35f78 to your computer and use it in GitHub Desktop.
async/await vs promise as monad
import { api } from '../api';
import { regUser } from './creators';
export const loadProject = projectId => async dispatch => {
const user = await api.loadProject(projectId);
dispatch(
regUser(user)
);
};
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