Classic Pattern for Managing Unsubscriptions
Learn about the classic pattern for managing unsubscriptions.
We'll cover the following...
Managing unsubscriptions
There are two commonly used ways to manage unsubscriptions: imperative and declarative patterns. Let’s look at both of these patterns in detail.
Imperative unsubscription management
The imperative unsubscription means manually calling the unsubscribe()
method on the subscription object we manage ourselves. The following code snippet illustrates this. We simply store the subscription inside a variable called subscription
and unsubscribe from the ngOnDestroy()
life cycle hook in the src/app/recipes-list/recipes-list.component.ts
...