code: function retry(isDone, next) {
              var currentTrial = 0,
                  maxRetry = 50,
                  interval = 10,
                  isTimeout = false;
              var id = window.setInterval(
                  function() {
                      if (isDone()) {
                          window.clearInterval(id);
                          next(isTimeout);
                      }
                      if (currentTrial++ > maxRetry) {
                          window.clearInterval(id);
                          isTimeout = true;
                          next(isTimeout);
                      }
                  },
                  10
              );
          }
docs: via: https://gist.github.com/cou929/7973956