Ember-data update from rest api

Hi everyone, i open a discuss on ember.js - ember-data update data from rest api - Stack Overflow

But after some responses i have some doubts and I decided to ask here.

I did a lot of researches on google/starckoveflow/ember doc for understand how to keep my frontend updated with backend and guarantee a good user expirince(no flickering) but I didn’t find nothing that clearly explain how to achieve my needs. So my doubt is that i didn’t understand emberjs and ember-data.

How can I keep my frontend data synced periodically with my backend? Is ember-data designed for this scope?

Have you already read this?

http://emberjs.com/guides/models/frequently-asked-questions/

@kgish yes, but:

in model hook i use this.store.filter instead this store.find and inside onPoll function i use controller.store.find(‘mymodel’).then(function(data){_this.store.pushMany(‘mymo‌ del’, data);});. And this works in part with no flickering: new records are added and existings are updated. The problem is when a record is deleted from backend. Is there the possibility to tell to pushMany function to remove records for which there isn’t an update?

edit

I have tried to put

controller.set('model', controller.store.find('mymodel'))

in Ember.Run(ember.js - Mitigating a flickering UI when refreshing content in Ember - Stack Overflow)

I create a simple demo at JS Bin - Collaborative JavaScript Debugging When you click on refresh you see a fast blinking in template.

In you refresh action:

  actions: {
    refresh: function(){
      this.store.unloadAll('Test');
      this.store.find('Test');
    }
  }

you unload all records of type ‘test’ and ask the sever to give you the entire list of ‘tests’. It’s ok but, you never use the result of this.store.find call. You need to do something with the result the server provides to your calls:

...
this.store.find('test').then(funtion(tests){
    do something with the new test record array
});

@nandosan something like this:

`refresh: function(){
  var _this = this;
  this.store.unloadAll('Test');
  this.store.find('Test').then(function(data){
    _this.store.pushMany('Test', data);
  });
} `

No. When you’ll be inside the success function of your fulfilled promise, your store as been already populated with the tests objects (which means received a json from the server, parsed/deserialized, created as many DS objects as needed - also related, sideloaded, ones -)

Your liveupdating objects will be auto-updated and you can do additional stuff in the promise success function.