Simple exponential backoff strategy for Ember.js promises
import retryWithBackoff from 'ember-backoff/retry-with-backoff';
export default Em.Route.extend({
model: function(params) {
retryWithBackoff(function() {
return this.store.find('user', 142857); //return any promise here
}, 5, 100); //retry 5 times: 100ms, 200ms, 400ms, 800ms, 1600ms between tries
}
});
Questions? Ping me @gavinjoyce
npm install ember-backoff --save-dev
- Better tests using sinon
- Other strategies: simply retry, fibonacci...
- High level support for Ember Data and Ember Model
Pull requests are very welcome, thanks.
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server