Skip to content
Snippets Groups Projects
lecturer-root.component.ts 1.29 KiB
import {Component, OnDestroy, OnInit} from '@angular/core';
import {takeWhile} from 'rxjs/operators';
import {LecturerViewService} from 'src/app/services/lecturer-view.service';

@Component({
  selector: 'app-lecturer-root',
  templateUrl: './lecturer-root.component.html',
  styleUrls: ['./lecturer-root.component.css']
})
export class LecturerRootComponent implements OnInit, OnDestroy {
  public onDashboard: Boolean;
  public onCreatePaper: Boolean;
  public onCreateTemplate: Boolean;
  public onTemplateView: Boolean;
  public isAlive = true;

  constructor(private lecturerViewService: LecturerViewService) {
  }

  ngOnInit(): void {
    this.lecturerViewService.onDashboard$.subscribe(flag => {
      this.onDashboard = flag;
    }).add(takeWhile(() => this.isAlive));
    this.lecturerViewService.onCreatePaper$.subscribe(flag => {
      this.onCreatePaper = flag;
    }).add(takeWhile(() => this.isAlive));
    this.lecturerViewService.onCreateTemplate$.subscribe(flag => {
      this.onCreateTemplate = flag;
    }).add(takeWhile(() => this.isAlive));
    this.lecturerViewService.onTemplateView$.subscribe(flag => {
      this.onTemplateView = flag;
    }).add(takeWhile(() => this.isAlive));

    this.lecturerViewService.changeToDashboard(true);
  }

  ngOnDestroy(): void {
    this.isAlive = false;
  }

}