Friday, November 1, 2013

It turns out there is a way to spin a timer to wait for a JavaScript promise to resolve, you just have to use a piece of the DOM as a middleman.

widget.kickOffPromiseToUpdateTextArea();
var loop = function(){
   var textarea = widget.ourTextArea;
   var characterCount = textarea.innerHTML.length;
   if (characterCount != 0) {
      clearInterval(interval);
      alert('made it!');
      goDoSomethingElseWithFeedBack(textarea.innerHTML);
   } else {
      alert('not yet!');
   }
};
var interval = setInterval(loop, 6000);

No comments:

Post a Comment