Ember-data update from rest api


Hi everyone, i open a discuss on http://stackoverflow.com/questions/28190412/ember-data-update-data-from-rest-api

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?



@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?


I have tried to put

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

in Ember.Run(http://stackoverflow.com/questions/14883553/mitigating-a-flickering-ui-when-refreshing-content-in-ember)


I create a simple demo at http://emberjs.jsbin.com/jebiqijimo/1/edit When you click on refresh you see a fast blinking in template.


In you refresh action:

  actions: {
    refresh: function(){

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:

    do something with the new test record array





@nandosan something like this:

`refresh: function(){
  var _this = this;
    _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.