We have now covered core concepts such as Observable, Observer, Producer, and operators. We have also looked into how we can manually create an Observable, but realized that there are different creation operators that will help you create Observables from other constructs, and sometimes the Angular framework itself will create the Observable for you. We have failed to mention one important thing though, cleanup. There will be situations where an Observable will allocate resources or simply go on forever, as with the interval() operator. There is one clear remedy to that—define and run a cleanup function when we are done with the Observable. Defining such a function forces us to return to the create operator and amend some code in its behavior function, like so:
let stream$ = Rx.Observable.create(observer => {
let counter = 0;
let id = setInterval(() => observer...