ember-graceful-retry-twitch
v0.0.5
Published
Retry any Promise-returning function with a custom backoff pattern.
Downloads
1
Readme
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.
});
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
) - Iftrue
, will repeat the last interval indefinitely.
The returned retryer
object also exposes many useful properties:
key | meaning
----|--------
isRetrying
| attempting the function
isWaiting
| is waiting to retry
waitSeconds
| how many seconds are remaining before the next retry?
errorCount
| how many times has the request failed?
isPending
| have we exhausted our retries?
isSettled
| !isPending
isFulfilled
| did the request succeed?
isRejected
| did all the retries fail?
Installation
git clone
this repositorynpm install
bower install
Running
ember server
- Visit your app at http://localhost:4200.
Running Tests
npm test
(Runsember 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/.