Skip to content

Instantly share code, notes, and snippets.

@panvourtsis
Last active March 8, 2019 14:59
Show Gist options
  • Save panvourtsis/a7226c4b575c7668d4291671d3c9bb5a to your computer and use it in GitHub Desktop.
Save panvourtsis/a7226c4b575c7668d4291671d3c9bb5a to your computer and use it in GitHub Desktop.
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