jeudi 7 mars 2019

Ember reset items in Ember data when returning to route

I have a route in my Ember app which returns a set of records in the model hook like so:

routes/dashboard.js

model() {
  return this.store.findAll('pending-post');
}

Assuming this returns 10 records, I can see the 10 records in the data tab of Ember Inspector, and when I log . The network tab also shows that an array of 10 records returned in the data object.

I then go to another route in my app and edit a post so that it is no longer pending. This change is persisted to the backend.

When I return to the dashboard, the model hook runs again. The request in the network tab now returns an array of 9 objects, as the API is only returning 9 items.

However, the data tab in Ember inpector still shows 10 items and there are still 10 items in .

What is the best way to force Ember data to remove the item that was not returned by the API the second time around?




Aucun commentaire:

Enregistrer un commentaire