Search code examples
typescriptionic-frameworkreactivex

Observable in parallel


I'm working with Ionic 3 and ReactiveX Observable objects. I've got an Observable through AngularFireDatabase with the method valueChanges(). I want to filter it in some ways like having some objects with a certain properties in another Observable and sort it too. I use Observable.forkJoin() but it doesn't work because my splashscreen doesn't hide. I can attach you some pieces of code if you need. Or maybe you can help me with some example. Thanks

Here is my code

Observable.forkJoin([
  this.allParticipants = this.participantsList.valueChanges().map(res => res.sort((a, b) => a.name < b.name ? -1 : 1)),
  this.paidParticipants = this.allParticipants.map(res => res.filter(guest => guest.paid)),
]).subscribe(() => this.splashScreen.hide(), () => this.splashScreen.hide(), () => this.splashScreen.hide());

I put the hiding method in all the params to find if in some ways it hides but it doesn't.


Solution

  • I think forkJoin didn't work here because it only emits, when all observables complete. valuesChanges() didn't complete. Use combineLatest or switchMap.