How to combine 3 firebase observables without losing dynamic updates

前端 未结 1 1639
无人及你
无人及你 2020-12-30 17:48

I have a 3 parallel firebase requires. And I need to join them as 1 single object. Code as below:

import {Http} from \"@angular/http\";
import {AngularFireD         


        
相关标签:
1条回答
  • 2020-12-30 18:28

    Instead of .forkJoin(...) you could use .combineLatest(...).

    I also did streamline your map a bit:

    Observable.combineLatest(
      this.db.list('participant/' + uid + '/threads'),
      this.db.list('participant/' + uid + '/messages'),
      this.db.list('participant/' + uid + '/participants')
    )
    .map(([threads, messages, participants]: [Thread[], Message[], Participant[]]) =>
      ({ threads, messages, participants })
    )
    
    0 讨论(0)
提交回复
热议问题