I have a hard time to grasp the way http Observables work.
Http get always completes, when only one value arrives but there is no way to look up the implementation. Do they always complete after error or a value arrives?
I have a lot of discussion with my collegues, because the use in every http operation the following procedure:
const sub = this.http.get( enviroment.baseUrl + '/users').pipe(take(1))
.subscribe( value => {
//do something with the value
},
error => consol.log(error.message));
And later this:
ngOndestroy():void{
sub.unsubscribe();
}
And for my understanding, pipe(take(1))
is not needed, because a http call emits always one value.
An response or a Error.
And since, a observable completes with one value, unsubscribing is not needed.
please correct me if I'm worng. I also would be pleased, to have official sources on this, if you have some in mind.
Thank you very much in advance