Last active
May 7, 2019 16:54
-
-
Save hendrikswan/c993b1f47c3f09023487e74f82101cf3 to your computer and use it in GitHub Desktop.
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
function loadDataEpic(action$) { | |
return action$ | |
.ofType('LOAD_DATA') | |
.switchMap(({ url }) => | |
fetch(url) | |
.then(response => response.ok ? response.json() : requestFailedAction()) | |
.then(result => result.type === 'REQUEST_FAILED' ? result : requestSuccessAction(result)) | |
.catch(() => requestFailedAction()) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment