Is it possible to get all the \"active\" subscriptions without storing them manually?
I\'d like to unsubscribe
all of the \"active\" subscriptions and don\'
You can just store one Subscription, and add to it.
private _subscriptions = new Subscription(); // yes you can do this!
Then add to it
_subscriptions.add(
this.layoutManager.width$.subscribe((w) => {
// any nested subscriptions can also use this mechanism
_subscriptions.add(...);
});
Then in ngOnDestroy()
you just call _subscriptions.unsubscribe();
.
I've been trying to make a 'clever' way to do this, but to be frank I've overengineered it quite a bit (including logging) and this is the simplest way I've come across.