Subscribing in the view using the async pipe

We have learned about RxJS observables and that they will not start to emit items if we don't subscribe to them. You can compare this to the analogy of the drain valve of a water pipe. If you don't open the drain, the water will not flow.

Within our updated task list component, we now have a filteredTasks observable to which we can subscribe to and obtain the latest filtered tasks. However, there's a slightly better way to handle RxJS subscriptions, which we're going to take a look at now.

The problem with subscriptions is that they always want to be cleaned up too. Imagine your subscription is causing many event handlers to be added and other resources which might get allocated for observing your ...

Get Mastering Angular Components now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.