Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
loadDocuments$ = this.actions$.pipe(
ofType<documentActions.Fetch>(documentActions.FETCH)
switchMap((action) =>
this.documentsService
.getDocuments().pipe(
map(docs => new documentActions.FetchSuccess(docs)),
catchError(error => of(
new ErrorOccurred({
action,
error,
})
))
)
)
)
@alex-okrushko

This comment has been minimized.

Copy link

@alex-okrushko alex-okrushko commented Aug 1, 2018

I think you want this:

  • action can be taken from the switchMap argument.
  • typo in err. You are using error in the new ErrorOccurred
loadDocuments$ = this.actions$.pipe(
   ofType<documentActions.Fetch>(documentActions.FETCH)
   switchMap((action) =>
       this.documentsService
         .getDocuments().pipe(
            map(docs => new documentActions.FetchSuccess(docs))
            catchError(error => of(
                  new ErrorOccurred({
                      action,
                      error,
                  })
              ))
          )
    )
)
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.