Hello I'm currently facing a problem with subscriptions when I navigate to another component of the app. The way I handle the subscriptions is on an array.
private _subscriptions: Subscription[] = [];
and every time I have to subscribe, I push the subscription to this array.
this._subscriptions.push(
this._headerService.rightIconClicked
.subscribe(() => this._logout())
);
on my ngOnDestroy method, I loop through this array and unsubscribe from every subscription.
if (this._subscriptions) {
this._subscriptions.forEach((sub: Subscription) => {
sub.unsubscribe();
});
}
To navigate, I'm using navigate()
method from angular router.
private _logout() {
this._router.navigate(['/login'])
}
And the error I get is the following:
Something to take in account is that on my ngOnDestroy() method, before unsubscribing, I have a console.log() to show that I'm there. And that is not even displayed. Thanks in advance.