Skip to content

Instantly share code, notes, and snippets.

@YasushiKobayashi
Created June 8, 2017 16:24
Show Gist options
  • Save YasushiKobayashi/739daa8822039381452d8fda9eab5571 to your computer and use it in GitHub Desktop.
Save YasushiKobayashi/739daa8822039381452d8fda9eab5571 to your computer and use it in GitHub Desktop.
reduxでmiddlewareを使わない非同期処理
export function isLogin() {
return async (dispatch) => {
try {
const user = await User.get('user');
dispatch({
type: actionTypes.LOADED,
isLoading: false,
isLogin: true,
user,
});
} catch (e) {
dispatch({
type: actionTypes.NOT_LOGIN,
isLoading: false,
});
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment