sorting - How to sort an Observable with Observable parameters ? rxjs -
i trying modify , sort list. noob @ :(
i able 'combinelatest' problem have modify array function below 'groupbydateandtournament'. outcome:
- create observable of list , sorting parameters (favoritetournaments, teamranks)
- modify list 'groupbyandtournament' if observable list has changed
- sort favorite if obsevable favoritetournament has changed
sort ranks if observable teamrank has changed
this.subscription = this.matchesservice.getupcoming() .merge( this.favoriteservice.getfavoritetournaments().flatmap((data) => { return {'favoritetournaments': data} }), this.teamsservice.getteamranking().flatmap((data) => { return {'teamranks': data} }) ).scan((acc, curr) => { let upcomingmatches; if (curr.upcoming) { upcomingmatches = this.groupbydateandtournament(curr); } if (curr.favoritetournaments) { upcomingmatches = this.sortbyfavorite(curr) } if (curr.teamranks) { upcomingmatches = this.sortbyrank(curr); } return upcomingmatches; }) .subscribe()
so managed combinelatest
observable.combinelatest( this.matchesservice.getupcoming().map((data)=> this.upcomingservice.combineupcomings(data)), this.favoriteservice.getfavoritetournaments(), this.teamsservice.getteamranking(), (matches, favoritetournaments, teamranks) => this.upcomingservice.prepareupcomingmatches(matches, favoritetournaments, teamranks) ).subscribe((data)=> this.ngzone.run(() => { this.upcomingmatches = data; this.loading = false; }) );
it still has issues.prepareupcomingmatches
function reruning when of observables changed.
Comments
Post a Comment