user3743222 user3743222 - 1 year ago 64
Javascript Question

rxjs observables lifecycle : detecting a completed observable

Is there a way to know if an

has completed AFTER the fact, i.e. after
call on the subscribers? This would be similar to the
method for iterators. I could not find anything in the doc (or elsewhere) on that subject.

For a cold observable, the question would not make so much sense, as one can resubscribe at will, and the observable will be started anew. For a time-limited hot observable, one could imagine the edge case of being passed a reference to that hot observable, and subscribing for its values, never receiving anything and not even knowing that nothing will ever be received.

Answer Source

Here is the answer I got from another channel (quoted below).

The "usual" channels of creating a hot observable, such as creating a subject or using .publish() will "replay" the terminal message (i.e., onError or onCompleted), but there is no such guarantee in general. I would argue though that any hot sequence that did not have this terminal message replay violates the contract of an observable, and appropriate bugs should be filed.