forkjoin returns no results

前端 未结 2 506
眼角桃花
眼角桃花 2021-01-21 12:46

I\'m using forkJoin to combine the results of two firebase requests

Both requests complete and log within the console, but the map function for the forkJoin itself does

相关标签:
2条回答
  • 2021-01-21 13:30

    This is my use case with Firestore.

     import { Observable } from 'rxjs/Observable';
     import { combineLatest } from 'rxjs/observable/combineLatest';
    
     constructor((){}
    
    getAllBudgetGroups() {
        const loading = this.loadingProvider.presentLoader();
        try {
         this.budgetGroups$ = this.budgetGroupProvider.getAllTempBudgetGroups().valueChanges();
         this.defaultBudgetGroups$ = this.budgetGroupProvider.getDefaultBudgetGroups().valueChanges();
         combineLatest(this.budgetGroups$, this.defaultBudgetGroups$).subscribe(([res1, res2]) => {
            this.budgetGroupSortedList = concat(res1, res2);
            this.loadingProvider.dismissLoader(loading);
         }, err => {
            console.log(err);
            this.loadingProvider.dismissLoader(loading);
          });
        }
        catch (err) {
          console.log(err);
          this.loadingProvider.dismissLoader(loading);
        }
      }
    
    0 讨论(0)
  • 2021-01-21 13:33

    It turns out forkJoin just doesn't work with firebase observables,

    When I updated to

    public initGroup(groupname, username){
      return Observable.combineLatest([
          this.getGroup(groupname, username),
          this.groupMembers(username, groupname)
    
      ])
        .map((data)=>{
          console.log(data)//This now logs
          this.group = data;
          return this.group
        })
    
    
    }
    

    combineLatest made it work as expected

    0 讨论(0)
提交回复
热议问题