vendredi 2 septembre 2016

Reload data in model every X minutes in Emberjs

I'm building a component which takes as an input an IP and returns the error log of that computer. I have setup my model and adapter and they work, but I want to reload the data every few minutes to see if there is a new message.

My component is like this:

import Ember from 'ember';

export default Ember.Component.extend({
  init(){
    this.logMessages = this.get('store').query('log', {ip : this.attrs.ip.value});
    this._super(...arguments);
  },

  didLoad: function(){
    var self = this;
    Ember.run.later(function(){self.logMessages = self.get('store').query('log', {ip : self.attrs.ip.value}); console.log("reload");}, 3000);
  }
});

For some reason I never see the run.later actually running and no errors or warning show up either.




Aucun commentaire:

Enregistrer un commentaire