I'm using the pattern from RxJs like so.
serviceThatMayNotComplete
.obtainObservableOfSomeKind(url)
.subscribe(res => console.log(res));
When the component is done, I understand that I need to unsubscribe to avoid memory leaks. Since I know that the service will only produce a single value, ever, I tried to find a version of subscribe
that only picks one element (a bit like the promisses did).
I've located take and first but it seems that they are operators on the set to be emitted and not how the consumption is performed.
Googling gave little I recognized as helpful but I might be using poor key words.
Is there a version of subscribe
that dies after a single response being delivered?