Sha256: b06ec7ef87ea51e0ef21a56d459422c5d84884498fd895266102000eccb7355b

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

(function(window) {
  window.waitFor || (window.waitFor = function(key, deepCheck, interval) {
    return function(callback) {
      var _called, _timer, checker;
      _timer = null;
      _called = false;
      setTimeout((function() {
        if (!_called) {
          return console.warn("not loaded component [" + key + "] in " + waitFor.timeout, typeof window[key]);
        }
      }), waitFor.timeout);
      checker = function() {
        if (_called || typeof window[key] === 'undefined') {
          return;
        }
        if (typeof deepCheck === 'function') {
          if (!deepCheck.call(window[key])) {
            return;
          }
        }
        clearInterval(_timer);
        _called = true;
        if (typeof callback !== 'function') {
          return;
        }
        return callback.call(window[key], window[key]);
      };
      _timer = setInterval(checker, interval || waitFor.tick);
      checker();
      return null;
    };
  });
  window.waitFor.timeout = waitFor.timeout || 30000;
  window.waitFor.tick = waitFor.tick || 100;
})(window);

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
izi_lightup-1.0.21 app/assets/javascripts/crit-utils/wait_for.js
izi_lightup-1.0.20 app/assets/javascripts/crit-utils/wait_for.js
izi_lightup-1.0.19 app/assets/javascripts/crit-utils/wait_for.js
izi_lightup-1.0.18 app/assets/javascripts/crit-utils/wait_for.js