mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-12-05 01:51:31 +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 { WebSocketService } from './websocket.service';
|
||||
import { Subject, BehaviorSubject, forkJoin } from 'rxjs';
|
||||
import { Subject, BehaviorSubject, merge } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
@ -13,13 +13,12 @@ export abstract class ConfigServiceBase {
|
||||
constructor(private webSocketService: WebSocketService) {}
|
||||
|
||||
init() {
|
||||
if (this.initDone) {
|
||||
return;
|
||||
}
|
||||
if (!this.initDone) {
|
||||
this.waitForMandatoryConfigs();
|
||||
this.subscribeConfigKeys();
|
||||
this.initDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
waitForMandatoryConfigs() {
|
||||
const firstConfigs = new Array<any>();
|
||||
@ -28,7 +27,7 @@ export abstract class ConfigServiceBase {
|
||||
firstConfigs.push(config.pipe(take(requiredEmitCount)));
|
||||
});
|
||||
|
||||
forkJoin(firstConfigs).subscribe(undefined, undefined, () => {
|
||||
merge(...firstConfigs).subscribe(undefined, undefined, () => {
|
||||
this.configDone.next();
|
||||
this.configDone.complete();
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { WebSocketService } from './websocket.service';
|
||||
import { Subject, BehaviorSubject, forkJoin } from 'rxjs';
|
||||
import { Subject, BehaviorSubject, merge } from 'rxjs';
|
||||
import { ConfigServiceBase } from './config.service.base';
|
||||
|
||||
@Injectable()
|
||||
@ -75,7 +75,7 @@ export class ConfigReadyService {
|
||||
recvdConfigDone.complete();
|
||||
});
|
||||
|
||||
forkJoin(this.readyNotifiers).subscribe(undefined, undefined, () => {
|
||||
merge(...this.readyNotifiers).subscribe(undefined, undefined, () => {
|
||||
this.configDone.next();
|
||||
this.configDone.complete();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user