Ember model reloading in interval

前端 未结 3 1491
无人共我
无人共我 2021-02-13 07:28

I have a User model, which has latitude and longitude properties, which are used to show current user location on map.

App.User = DS.Model.extend({
    firstName         


        
3条回答
  •  眼角桃花
    2021-02-13 07:42

    EDIT: Please see Dmitri Zagidulin's answer.

    So I figured it out. For now all I need was to override didLoad method on model, in future I will probably need more complex solution, but this is adequate for now.

    didLoad: function(){
      var self = this;
      setInterval(function() {self.reload()}, 5*60*1000); //every 5 minutes
    }
    

    In case someone needs to reload more models, good solution would be to implement this as Mixin.

提交回复
热议问题