timeout-promise

1.0.2 • Public • Published

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();
  });

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i timeout-promise

    Weekly Downloads

    7

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • shuvalov-anton