Try to reload model on any ajax error


#1

How I can make my app to continue poll for model every time backend fails? I already tried everything in order to achieve this behaviour, but seems I am not capable to do it properly. I use plain jquery ajax calls. I tried to retry current transition in catch-all error action:

// application route

actions: {
  error(error, transition) {
    if (error) {
      this.retryTransition(transition);
    }
  }
},

retryTransition(transition) {
  return Ember.run.later(this, () => {
    transition.retry().catch(() => {
      this.retryTransition(transition)
    })
  }, 5000);
}

In all routes with models I have the following code:

setupController: function(controller, model) {
  this._super(controller, model);
  Ember.run.later(this, this.refresh, 5000); // periodically poll backend for data
},

but only nested route model can back up after failure, and if I click parent links, models never update for these routes.

is there any recommended solution that I can use?