Skip to content

Instantly share code, notes, and snippets.

@vvscode
Created February 8, 2019 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvscode/c7859854ffb5730c0c795b80999dbf92 to your computer and use it in GitHub Desktop.
Save vvscode/c7859854ffb5730c0c795b80999dbf92 to your computer and use it in GitHub Desktop.
handle-api-call-state-nicely
@Effect()
loadNews = this.actions$.pipe(
ofType(NewsActionsTypes.Load),
switchMap(action => {
return this.http.get('some url').pipe(
map((response: any) => new LoadNewsSuccess({entities: response.todaysNews})),
catchError(error => of(new LoadNewsError(error)))
);
}),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment