Skip to content

Instantly share code, notes, and snippets.

@adrianfaciu
Last active October 2, 2018 07:09
Show Gist options
  • Save adrianfaciu/828b3ab47ba2a03a5032e639444fb1d7 to your computer and use it in GitHub Desktop.
Save adrianfaciu/828b3ab47ba2a03a5032e639444fb1d7 to your computer and use it in GitHub Desktop.
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
Copy link

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