Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
fix: add sub to explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
artemnih committed Mar 3, 2022
1 parent 9ea408e commit c1dcb6d
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { Component, Inject, OnDestroy, ViewEncapsulation } from '@angular/core';
import { BehaviorSubject, Subscription } from 'rxjs';
import { AvialableView } from '../../common/types';
import { CURRENT_VIEW } from '../../injection-tokens/current-view.token';

Expand All @@ -9,15 +9,20 @@ import { CURRENT_VIEW } from '../../injection-tokens/current-view.token';
styleUrls: ['./explorer.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class ExplorerComponent {
export class ExplorerComponent implements OnDestroy {

public avialableView = AvialableView;
public view: string;
private sub = new Subscription();

constructor(@Inject(CURRENT_VIEW) private currentView: BehaviorSubject<AvialableView>) {
this.currentView.subscribe(view => {
this.sub.add(this.currentView.subscribe(view => {
this.view = view;
})
}));
}

ngOnDestroy() {
this.sub.unsubscribe();
}

}

0 comments on commit c1dcb6d

Please sign in to comment.