Using Angular’s async pipe to unsubscribe streams automatically
As you learned in the previous recipe, it is crucial to unsubscribe the streams you subscribe to. What if we had an even simpler way to unsubscribe them when the component gets destroyed—that is, letting Angular take care of it somehow? In this recipe, you’ll learn how to use Angular’s async
pipe with an observable to directly bind the data in the stream to the Angular template instead of having to subscribe in the *.component.ts
file.
Getting ready
The app that we are going to work with resides in start/apps/chapter05/ng-async-pipe
inside the cloned repository: