Edit:
The fromFetch function, which I think creates a complete event on the observable after the fetch? But I have not used it myself yet. It's been a while since I used RXJS regularly. And otherwise rather directly from Angular. There you normally use the HttpClient from angular.
Edit2:
oh, and if I see it right, is the subscribe not on the fromEvent observable?
As long as I see it, fromFetch wraps the native fetch in an observable that handles cancellations for you.
The subscribe is bound to the entire observable that precedes it (after the fromFetch some additional transformations are applied).
Having said that, I'm not on expert of RxJs. For example, I'm not totally sure if the flatMap shouldn't have been a switchMap. I guess, in general, it's safer to use switchMap as a default when only one inner subscription should be active at once.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
you can add a tap function?
Edit:
The fromFetch function, which I think creates a complete event on the observable after the fetch? But I have not used it myself yet. It's been a while since I used RXJS regularly. And otherwise rather directly from Angular. There you normally use the HttpClient from angular.
Edit2:
oh, and if I see it right, is the subscribe not on the fromEvent observable?
Hey Felix. I'm not sure I understand the comment.
As long as I see it,
fromFetch
wraps the nativefetch
in an observable that handles cancellations for you.The
subscribe
is bound to the entire observable that precedes it (after thefromFetch
some additional transformations are applied).Having said that, I'm not on expert of RxJs. For example, I'm not totally sure if the
flatMap
shouldn't have been aswitchMap
. I guess, in general, it's safer to useswitchMap
as a default when only one inner subscription should be active at once.