title: Force code to execute after another method finishes executing
body: <p>Here is what I want to do:</p>
  
  <p>setSource is a function which executes about 3 seconds.</p>
  
  <pre><code> editor.setSource();
  
   setTimeout(function () {
        //do something, some commands
   }, 3000);
  </code></pre>
  
  <p>I want the //do something, some commands part to be executed AFTER the last line of setSource() is executed. Now I'm doing it with setTimeout, but I think it's not very good solution, because sometimes setSource() will take maybe 5 seconds to execute. How to do this?</p>