If it is a heavy http request you will be doing this twice, unless you use a sharereplay(1) or a ReplaySubject(1). If it is a request to create a record...
Well, what I mean is that we may have a problem here, right?
If it is a heavy http request you will be doing this twice, unless you use a shareReplay(1) or a ReplaySubject(1)
Depends on the observable.
Well, what I mean is that we may have a problem here, right?
I can't answer that for you. I'm not familiar with your project. If you're unsure how to use observables, you can always just stick to promises (or transform observables to promises with toPromise()).
I'll note that Angular's HttpClient returns observables which complete after the request resolves. If you're using it, this isn't something you need to worry about.
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.
Hi! Another question. I'm trying to understand all of your logic...
If
this.isLoadingService.add
receive anObservable
you subscribe to it, here. And the same input Observable is returned.And in your example, you subscribe again within your component, here:
<profile-component *ngFor="let user of users | async" [user]='user'>
The observable is executed twice. Or did I miss something? Can you explain me?
Tks!!
Yup. The observable is subscribed to twice. Once by the
isLoadingService
, and once by theasync
pipe in the component's template.If it is a heavy http request you will be doing this twice, unless you use a
sharereplay(1)
or aReplaySubject(1)
. If it is a request to create a record...Well, what I mean is that we may have a problem here, right?
Thanks again!
Depends on the observable.
I can't answer that for you. I'm not familiar with your project. If you're unsure how to use observables, you can always just stick to promises (or transform observables to promises with
toPromise()
).I'll note that Angular's
HttpClient
returns observables which complete after the request resolves. If you're using it, this isn't something you need to worry about.