Last active
October 17, 2019 00:12
-
-
Save Sawtaytoes/d74a7e66b0ab3d4926e57d99f7a4dd09 to your computer and use it in GitHub Desktop.
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
const fetchUserEpic = ( | |
action$, | |
) => ( | |
action$ | |
.pipe( | |
ofType(FETCH_USER), | |
switchMap(({ | |
password, | |
username, | |
}) => ( | |
merge( | |
( | |
of( | |
setLoading( | |
'login', | |
) | |
) | |
), | |
( | |
ajax | |
.getJSON( | |
'https://api.example.com/login' | |
) | |
.pipe( | |
switchMap(({ | |
authToken, | |
}) => ( | |
of( | |
( | |
fetchUserSucceeded( | |
authToken | |
) | |
), | |
( | |
setLoaded( | |
'login', | |
) | |
), | |
) | |
)), | |
catchError(( | |
error, | |
) => ( | |
of( | |
fetchUserFailed( | |
error, | |
) | |
) | |
)), | |
) | |
), | |
) | |
)), | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment