rxjs concatMap sequence -


i'm confused. please help! don't understand why of second promise in example emitted @ end when use concatmap(), , shoud wrong. how can right sequence waiting promise result (when promise got, next promise should start). @ concatmapto() , scan() can't understand how can @ example. tryed concatall(), waiting promise start subscribing not end of previos promise result.

jsbin http://jsbin.com/napasekemu/1/edit?js,console

example, sorry size can't more 2 links

code jsbin.com/tusolipofu/edit?js,console if link don't work:

const mysubject = new rx.subject(); let counter = 1; const source = mysubject.concatmap(v => rx.observable.from(v())) const subscribe = source.subscribe(val => console.log(val), err =>  console.log(err), () => console.log('complete')); mysubject.next(()=> {    return new promise(resolve => {        [10000,11000,12000,13000,14000,15000].foreach(e =>             mysubject.next(()=> {            return new promise(resolve => settimeout(()=> resolve(`${e} inner             each!`), e/2));        }));        resolve(`1 world!`)    }); });   [10,20,30].foreach(e => {     mysubject.next(()=> {          return new promise(resolve => settimeout(()=> resolve(`${e}           world!`),           7000));     }); });  mysubject.next(()=> {   return new promise(resolve => settimeout(()=> resolve(`6 world!`),    10000)); });  mysubject.next(()=> {    return new promise(resolve => resolve(`5 world!`)); });  mysubject.next(()=> {    return new promise(resolve => settimeout(()=> resolve(`7 world!`),  7000)); });   mysubject.next(()=> {    return new promise(resolve => settimeout(()=> resolve(`8 world!`),   7000));  }); 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -