Advertisement
vawerv

Async to sync

Aug 16th, 2012
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Without modules for any asynchronous functions:
  2.  
  3. step1();
  4.  
  5. function step1 () {
  6.   exec('COMMAND', onStep1Ready);
  7. }
  8.  
  9. function onStep1Ready () {
  10.   //handling results
  11.   step2();
  12. }
  13.  
  14. function step2() {
  15.   exec('COMMAND', onStep2Ready);
  16. }
  17.  
  18. function onStep2Ready () {
  19.   //handling results
  20.   step3();
  21. }
  22.  
  23. //... and so on
  24.  
  25. function finish () {
  26.   // display results
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement