import {EventEmitter, Injectable} from '@angular/core'; import { Subscription, timer, zip} from 'rxjs'; // import {ScreenOxService} from './screen-ox.service'; import {CommunicationOxService} from 'ox-core'; import {first, takeUntil, tap} from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class InWumboxService { protected timerSubscription: Subscription; public inWumbox: EventEmitter = new EventEmitter(); public notInWumbox: EventEmitter = new EventEmitter(); constructor(private communication: CommunicationOxService) { zip(this.communication.receiveSettings, this.communication.receiveI18NInfo, this.communication.receiveMicroLessonInfo) .pipe(first()) .subscribe((e) => { this.timerSubscription.unsubscribe(); this.inWumbox.emit(true); this.inWumbox.complete(); }); this.timerSubscription = timer(5000, 1000) .pipe(takeUntil(this.inWumbox)) .subscribe((e) => { this.showNotInWumboxScreen(); }); } public showNotInWumboxScreen() { this.notInWumbox.emit(); // this.screenService.showNotInWumboxScreen(); } }