Created
June 8, 2017 16:24
-
-
Save YasushiKobayashi/739daa8822039381452d8fda9eab5571 to your computer and use it in GitHub Desktop.
reduxでmiddlewareを使わない非同期処理
This file contains hidden or 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
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