rxjs - How to return from within an observer? -


i trying return filter function return doesn't seem work callbacks. here this.store.let(getispersonalized$) observable emitting boolean values , this.store.let(getplayersearchresults$) observable emiting objects of video class. how run synchronously, can avoid asynchronus callback altogether given can't modify observables received store.

ispersonalized$ = this.store.let(getispersonalized$); videos$ = this.store.let(getplayersearchresults$)                                            .map((vids) => this.myfilter(vids));  myfilter(vids) {    this.ispersonalized$.subscribe((x){       if(x){          return this.fileterx(vids);//return here       }       else {          return this.filtery(vids);//or return here       }   }); }  fileterx(vids) {   return vids.filter((vid) => vids.views>100;); }  filetery(vids) {   return vids.filter((vid) => vids.views<20;); } 

i got working way, don't need myfilter(vids) @ if can branching out on ispersonalized$'s subscribe. here updated code.

  this.store.let(getispersonalized$);   videos$: observable<any>;    ngoninit() {     this.ispersonalized$.subscribe((x) => {       if (x) {         this.videos$ = this.store.let(getplayersearchresults$)                         .map((vids) => this. fileterx(vids));       } else {         this.videos$ = this.store.let(getplayersearchresults$)                         .map((vids) => this. filetery(vids));       }     });   }    fileterx(vids) {     return vids.filter((vid) => vids.views>100;);   }    filetery(vids) {     return vids.filter((vid) => vids.views<20;);   } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -