Skip to content

Instantly share code, notes, and snippets.

@praveenpuglia
Created April 25, 2018 18:46
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 praveenpuglia/19547c51a90ffc3ebb81a57ec09b49ea to your computer and use it in GitHub Desktop.
Save praveenpuglia/19547c51a90ffc3ebb81a57ec09b49ea to your computer and use it in GitHub Desktop.
Cancel in flight / ongoing network request - ngrx effects
@Effect()
getTabData$: Observable<Action> = this.actions$.pipe(
ofType<FetchTabData>(TabActions.FETCH_TAB_DATA),
switchMap(action => {
const tabType = action.payload;
return this.http
.get(`${environment.apiUrl}/api/tab/${tabType}`)
.pipe(
map((response: any) => {
return new FetchTabDataSuccess(response.data);
}),
catchError(error => of(new FetchTabDataFailure(error)))
);
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment