Jump to content

Promise dependency


[dx]

Recommended Posts

Hello after long time.

How are you guys?

 

I stuck with one problem about Promises.

 

I'm working on service which collects data from some services and join them to object to output.

 

My current code is like:

 

var p1 = async_thenable_method(),

p2 = async_thenable_method(),

p3 = async_thenable_method();

 

Promise.resolve([ p1, p2, p3 ]).then(function® {

...

});

 

That's quite easy but problem is that I have also one method which is dependency for one of them so i need wait for one promise to finish, and then take that data to another method.

 

I tried to make Promise in promise but can't get it working.

 

Which is right way to deal with this?

 

Thanks.

Link to comment
Share on other sites

Hmmm... although I bought a book about Javascript promises I have to admit that I have not gotten around to learning much about this topic yet.

 

Can you expand the example code below so that it describes your situation?

 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...