mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 01:41:32 +00:00
Fix "wait for all observables to complete" logic ConfigServiceBase
This commit is contained in:
parent
a88415bad1
commit
5a8f653f1a
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { WebSocketService } from './websocket.service';
|
import { WebSocketService } from './websocket.service';
|
||||||
import { Subject, BehaviorSubject, forkJoin } from 'rxjs';
|
import { Subject, BehaviorSubject, merge } from 'rxjs';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -13,12 +13,11 @@ export abstract class ConfigServiceBase {
|
|||||||
constructor(private webSocketService: WebSocketService) {}
|
constructor(private webSocketService: WebSocketService) {}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
if (this.initDone) {
|
if (!this.initDone) {
|
||||||
return;
|
this.waitForMandatoryConfigs();
|
||||||
|
this.subscribeConfigKeys();
|
||||||
|
this.initDone = true;
|
||||||
}
|
}
|
||||||
this.waitForMandatoryConfigs();
|
|
||||||
this.subscribeConfigKeys();
|
|
||||||
this.initDone = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForMandatoryConfigs() {
|
waitForMandatoryConfigs() {
|
||||||
@ -28,7 +27,7 @@ export abstract class ConfigServiceBase {
|
|||||||
firstConfigs.push(config.pipe(take(requiredEmitCount)));
|
firstConfigs.push(config.pipe(take(requiredEmitCount)));
|
||||||
});
|
});
|
||||||
|
|
||||||
forkJoin(firstConfigs).subscribe(undefined, undefined, () => {
|
merge(...firstConfigs).subscribe(undefined, undefined, () => {
|
||||||
this.configDone.next();
|
this.configDone.next();
|
||||||
this.configDone.complete();
|
this.configDone.complete();
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { WebSocketService } from './websocket.service';
|
import { WebSocketService } from './websocket.service';
|
||||||
import { Subject, BehaviorSubject, forkJoin } from 'rxjs';
|
import { Subject, BehaviorSubject, merge } from 'rxjs';
|
||||||
import { ConfigServiceBase } from './config.service.base';
|
import { ConfigServiceBase } from './config.service.base';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -75,7 +75,7 @@ export class ConfigReadyService {
|
|||||||
recvdConfigDone.complete();
|
recvdConfigDone.complete();
|
||||||
});
|
});
|
||||||
|
|
||||||
forkJoin(this.readyNotifiers).subscribe(undefined, undefined, () => {
|
merge(...this.readyNotifiers).subscribe(undefined, undefined, () => {
|
||||||
this.configDone.next();
|
this.configDone.next();
|
||||||
this.configDone.complete();
|
this.configDone.complete();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user