Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
.asObservable dont want to work with Observable.forkJoin

I have service:

export class ConfigService {
  private _config: BehaviorSubject<object> = new BehaviorSubject(null);
  public config: Observable<object> = this._config.asObservable();

  constructor(private api: APIService) {
    this.loadConfigs();
  }

  loadConfigs() {
   this.api.get('/configs').subscribe( res => this._config.next(res) );
  }
}

Trying to call this from component:

...
Observable.forkJoin([someService.config])
  .subscribe( res => console.log(res) ) //not working 

someService.config.subscribe( res => console.log(res) ) // working
...

How can i use Observable.forkJoin with Observable variable config?

I need to store configs in service and wait unlit them and others request not finished to stop loader.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since you're using BehaviorSubject you should know that you can call next() and complete() manually.

The forkJoin() operator emits only when all of its source Observables have emitted at least one values and they all completed. Since you're using a Subject and the asObservable method the source Observable never completes and thus the forkJoin operator never emits anything.

Btw, it doesn't make much sense to use forkJoin with just one source Observable. Also maybe have a look at zip() or combineLatest() operators that are similar and maybe it's what you need.

Two very similar question:

  • Observable forkJoin not firing
  • ForkJoin 2 BehaviorSubjects
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!