I'm having trouble finding what happens to an Observable when it has completed. I have an observable that must complete before I do other work. To do this, my other functions subscribe that observable, and when it's complete, they do their work.
The question I have is what happens when they subscribe after the Observable is complete? From my testing, it appears they get the last value and then it completes (It fires value
and complete
callbacks on the subscribe
method). I'd rather just not subscribe to it to begin with if it has already completed.
Is there a way to check if an Observable has completed without subscribing? I was setting it undefined when complete, but it creates an issue if I'm subscribed to observable from another function when that occurs.
I could create a behavior subject isLoaded
which starts off as False, and goes to true when it's done, but I'm having trouble finding documentation on what a completed observable does when subscribed to and what the best practice is. Thank you!
Edit: This is not asking how to check if an observable is complete. It's asking what happens if an observable completed from a different subscription, how you can check that it had completed. What happens to an observable when it is complete and you look at the Observable object.