Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Effect()
addCartItem: Observable<Action> = this.actions$.pipe(
ofType<cartActions.AddItem>(cartActions.ADD_ITEM),
concatMap(({ itemId }) =>
this.cartService.addToCart(itemId).pipe(
// Notice, that nothing is passed to the Success.
map(() => new cartActions.AddItemSuccess()),
// passing the itemId to the Error, so it can be restored.
catchError(() => of(new cartActions.AddItemError(itemId)))
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.