[Library | Trunk]

Add clearSubscription in layout service



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59846 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-11-13 16:34:39 +00:00
parent 4e455a9e0d
commit a9a0d270cb
1 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import {Injectable} from "@angular/core";
import {BehaviorSubject, Observable} from "rxjs";
import {BehaviorSubject, Observable, Subscriber} from "rxjs";
import {ActivationStart, Router} from "@angular/router";
@Injectable({
@ -36,8 +36,19 @@ export class LayoutService {
private _isFrontPageSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
private _isSmallScreenSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
sub:any;
ngOnDestroy() {
this.clearSubscriptions();
}
clearSubscriptions(){
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
constructor(private router: Router) {
this.router.events.subscribe(event => {
this.sub = this.router.events.subscribe(event => {
if (event instanceof ActivationStart) {
let data = event.snapshot.data;
if (data['hasSidebar'] !== undefined &&