Skip to content

Instantly share code, notes, and snippets.

@CharlieGreenman
Created November 10, 2019 14:42
Show Gist options
  • Save CharlieGreenman/575f535ede2700fb137ad9ceb9fb0a0c to your computer and use it in GitHub Desktop.
Save CharlieGreenman/575f535ede2700fb137ad9ceb9fb0a0c to your computer and use it in GitHub Desktop.
mergeMap effects example
@Effect()
loadAllBlogPosts$: Observable<any> = this.actions$.pipe(
ofType(PokemonActions.loadPokemon),
mergeMap(() =>
this.postsService.getAll().pipe(
map(posts => PokemonActions.loadPokemonSuccess({ posts })),
catchError(message => of(PokemonActions.loadPostsFailed({ message })))
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment