1.0.2 • Published 11 years ago

timeout-promise v1.0.2

Weekly downloads
24
License
MIT
Repository
github
Last release
11 years ago

Build Status Code Climate

Timeout Promise

Simple util to check async changes that hasn't any callback API. Just dirty checks based on promise progress triggered by intervals. Useful for banners and adverts loaded optionaly.

Install

npm install timeout-promise

Example

var el = $('.js-adverts'); 
var promise = new Watcher({ 
  counter: 10, // after that attempts promis will be rejected
  interval: 1000 // interval in ms to trigger .progress callback
});

promise
  .progress(function (promise) {
    // if somthing is loaded
    $el.find('.banner').length
      && promise.resolve();
  })
  .done(function() {
    $el.show();
  })
  .fail(function() {
    $el.remove();
  });