0
votes

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.

1
Please add some code in order to let us help you. - user6749601
I need to do those operations to store some infos about my participants, is there a way to call them in parallel or in series and how i can wait all the subscription onCompleted methods? - james watt
Have you looked into using the forkJoin operator? learnrxjs.io/operators/combination/forkjoin.html - Daniel W Strimpel
I will take a look. Thanks - james watt
It doesn't work, I don't know why, I edit the question right now. - james watt

1 Answers

0
votes

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