javascript - Is there any pattern to orchestrate function calls besides Promises? -


I am trying to escape from the pyramid of doom. Imagine the following function call series:

  $ Wait (1000) .done (function () {// do something. $ (.5000) .watt (function () {// Do some more. $ 22. (don't) function () {// something More}}};});});   

Where the $ .wait function is defined:

  $. Wait = ceremony (period) {return $. Idle (function (dfd) {setTimeout (dfd.resolve, duration);}); };   

The question is how can I refract the above code so that it can be readable?

OK, you already have in the promise in your code (or At least, suspended), so there is no good reason to see different coding patterns. Although you can callback the promise with Chening all along with nesting (instead of done ):

  $ Wait (1000) .then (function () {// ^^^^ // some refund $. Wait (5000); // ^^^^^}}. Then (function () {// ^^^ ^ // Do something else. Return to Weight (2000); // ^^^^^^} then (function () {// ^^^^ // do something else});  < / pre> 

which is equivalent to your code.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -