The next thing you should know is how to complete an observable when the observable has reached the end of its life cycle.
It will send a completed signal we can see this with a timer using the finally operator which will run the code. Once the observable is completed.
In this case, it will be completed after one second so we subscribe and then we get the all done signal back.
However there are other observables that won’t complete automatically. And in some cases this can result in memory leaks.
If it’s a very data-intensive stream here we have an interval which doesn’t complete on its own. So what we do is subscribe to it first then set a timeout for three seconds.
And call unsubscribe this manually forces the observable to send the complete signal.
There’s also more clever ways to do this which we’re going to see a little bit later in the lesson.