javascript - How do I create a promise chain in js shaped like a diamond -


i'm stuck promises.

say program structure this

            func             //gets data passes i1 , j2          /          \       func i1      func j1     //then route & j run without interaction         |            |       func i2      func j2               \          /              func b            //func b gets both result of both 

i'm have bit of trouble getting work. i'm far as

  getdata.then(data=>{       var methods = promise.all([         funci1.x(data).then(output=>{           funci2.x(output)         }),         funcj1.x(data).then(output2=>{           funcj2.x(output2)         })       ])       methods.then(([a,b])=>{         console.log(a,b);       })   }) 

but doesn't seem working. help?

you don't return can casted promise in 2 then() callbacks, change this:

getdata.then(data => {   var methods = promise.all([     funci1.x(data).then(output => funci2.x(output)),     funcj1.x(data).then(output2 => funcj2.x(output2))   ])   methods.then(([a, b]) => {     console.log(a, b);   }) }) 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -