Last active
March 8, 2019 14:59
-
-
Save panvourtsis/a7226c4b575c7668d4291671d3c9bb5a 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
import { from, of, concat } from 'rxjs'; | |
import { catchError, mergeMap, switchMap } from 'rxjs/operators'; | |
const exampleEpic = action$ => | |
action$.pipe( | |
ofType(types.ACTION_REQUEST), | |
switchMap(({ payload }) => | |
concat( | |
of(loadingList()), // Here we define the loading action for our list | |
from(api.get(payload.data)).pipe( | |
mergeMap(response => | |
of( | |
addDataAction(response), // action 1 | |
pushInfoSnackbar('created successfully') // action 2 | |
) | |
), | |
catchError(() => | |
of(pushWarningSnackbar('Failed to create shareable folder')); // failed action | |
) | |
) | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment