0.0.5 • Published 4 months ago

ember-graceful-retry-twitch v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

ember-graceful-retry lets you retry a Promise-returning function.

example

import retry from 'ember-graceful-retry/retry';

let getUsers = function() {
  // return a promise object.
};

let retryer = retry(getUsers, { intervals: [1, 1, 3, 6] }).then(function(users) {
  // once it succeeds.
}).catch(function(error) {
  // only executed if we've exhausted all retries.
});

ember-graceful-retry demo

signature

retry(fn, [options]);
  • fn - any function that returns a (spec-compliant) Promise
  • options - required
    • intervals required - the amount of time to wait between retries.
    • isRepeating (default: false) - If true, will repeat the last interval indefinitely.

The returned retryer object also exposes many useful properties:

keymeaning
isRetryingattempting the function
isWaitingis waiting to retry
waitSecondshow many seconds are remaining before the next retry?
errorCounthow many times has the request failed?
isPendinghave we exhausted our retries?
isSettled!isPending
isFulfilleddid the request succeed?
isRejecteddid all the retries fail?

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

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

0.0.5

4 months ago