0.0.3 • Published 9 years ago

ember-timed-promise v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
9 years ago

Ember-timed-promise

This is an extension of Ember.RSVP.Promise that allow the user to set a Timer that will reject the promise if not resolved in time. It uses ES6 syntax internally and babel to compile to ES5 friendly code

Basic Usage

It works like a normal promise, only it accepts a time (in ms) and a promise/jQuery Deferred as an input and a custom message error (Will default to "ms timer exceeded").

Ember.RSVP.Promise

let prom = new Ember.RSVP.Promise((resolve, reject) =>{
  Ember.run.later(function() {
    resolve({
      response: true
    });
  }, 150); // This will delay the promise execution of 150ms
});

// The promise will reject and throw an error after 100ms
return new TimedPromise(100, prom, "It Failed!").then((response) => {
    Ember.Logger.log(response); // Will log {response : true}
  }, (reason) => {
    Ember.Logger.log(reason);
    // Will log Error("It Failed!")
});

jQuery Deferred

let prom = Ember.$.getJSON("https://api.github.com/repos/emberjs/ember.js/pulls");
return new TimedPromise(2000, prom).then((response) => {
   Ember.Logger.log(response); // Will have an array of pulls from the ember repo
}).catch((reason) => {
   Ember.Logger.log(reason); // Why did you fail?
   });

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago