javascript - switchMap not accepting a function to be executed inside it -


i have following search try execute:
want search based on first id, returns firebaselistobservable. try execute code inside switchmap function of observable because search takes bit longer , code finished otherwise , wrong values lastloc used.

i try run series of points loop through array in beginning.

here code:

evaluateroutes() {   this.currenttour.traveldistance = 0;   this.currenttour.traveltime = 0;   this.currenttour.worktime = 0;   const locs = this.currenttour.locids;   let lastloc = null;   locs.foreach(loc => {     console.log(lastloc, loc);     if (lastloc !== null) {       console.log('if durch', lastloc, loc);       this.afdb.list('routes', {         query: {           orderbychild: 'idstart',           equalto: loc         }       }).switchmap(items => {         console.log('switchmap starts', lastloc, loc);         const filtered = items.filter(item => item.idend === lastloc);         const route = filtered[0];         this.currenttour.routeids.push(route.$key);         this.currenttour.routes.push({           idend: route.idend,           idstart: route.idstart,           traveldistance: route.traveldistance,           traveltime: route.traveltime,           tscreated: route.tscreated,           usercreated: route.usercreated         });         this.currenttour.traveldistance = +0 + this.currenttour.traveldistance + route.traveldistance;         this.currenttour.traveltime = +0 + this.currenttour.traveltime + route.traveltime;       }).subscribe();     }     lastloc = loc;   }); } 

i receive following error:

argument of type '(items: any) => void' not assignable parameter of type '(value: any, index: number) => observableinput<{}>'.   type 'void' not assignable type 'observableinput<{}>'. 

you should use observable's do method when don't need modify stream.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -