Saturday, 7 September 2013

How to use promises in functions that can be called in various orders?

How to use promises in functions that can be called in various orders?

My goal is pretty simple. I have a bunch of aysync utility functions that
are called in various orders.
Right not it's like this:
doSomething(doNextThing(doFinalThing));
But it's becoming unwieldy. My goal is to have a syntax like this:
doSomething.then(doNextThing).then(doFinalThing)
but with the ability for the order to change:
doNextThing.then(doSomething).then(doFinalThing)
How would I go about implementing these functions so that they are all
promise-aware?

No comments:

Post a Comment