lundi 26 janvier 2015

Ember Data - ArrayController's content does not reload, after adding new items by store.pushPayload method

I have a list of items handling by Ember.ArrayController. I'm doing some PATCH action on records, which updates existing items and adding a new ones, if it is needed from the context. All changes I'm sending back from the server and I'm pushing it to the store by using Store.pushPayload() method.


I do something like that:


All changes in existing records are automatically updated - so observers of particular items are run. Unfortunately when I have a new items in payload - they do not appear on the list - observes of ArrayController.content are not called.


I also tried to manually notify ArrayController about the changes by doing:



_this.store.pushPayload(response);

var tasksController = _this.get('controllers.tasks');
tasksController.contentDidChangedManually();


And in controller:



contentDidChangedManually: function() {
this.set('contentChangedManually', new Date().getTime());
},
filteredContent: function() { // my content filters... }.property('arrangedContent', 'contentChangedManually')


But it does not work, because contentDidChangedManually() is run before pushing a payload is done. Unfortunately, Store.pushPayload() does not return a promise, so I can't run it when new records are ready.


Does anyone have a solution for this? Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire