Created
February 8, 2019 10:36
-
-
Save vvscode/c7859854ffb5730c0c795b80999dbf92 to your computer and use it in GitHub Desktop.
handle-api-call-state-nicely
This file contains 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
@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