mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 11:52:54 +00:00 
			
		
		
		
	Fix "wait for all observables to complete" logic ConfigServiceBase
This commit is contained in:
		@@ -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,12 +13,11 @@ export abstract class ConfigServiceBase {
 | 
			
		||||
  constructor(private webSocketService: WebSocketService) {}
 | 
			
		||||
 | 
			
		||||
  init() {
 | 
			
		||||
    if (this.initDone) {
 | 
			
		||||
      return;
 | 
			
		||||
    if (!this.initDone) {
 | 
			
		||||
      this.waitForMandatoryConfigs();
 | 
			
		||||
      this.subscribeConfigKeys();
 | 
			
		||||
      this.initDone = true;
 | 
			
		||||
    }
 | 
			
		||||
    this.waitForMandatoryConfigs();
 | 
			
		||||
    this.subscribeConfigKeys();
 | 
			
		||||
    this.initDone = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  waitForMandatoryConfigs() {
 | 
			
		||||
@@ -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();
 | 
			
		||||
    });
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user