Fix "wait for all observables to complete" logic ConfigServiceBase

This commit is contained in:
Kristóf Tóth 2019-08-28 11:13:51 +02:00
parent a88415bad1
commit 5a8f653f1a
2 changed files with 8 additions and 9 deletions

View File

@ -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();
});

View File

@ -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();
});