Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DEPRECATION: The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one

At the moment of this question i'm running the latest Ember and Ember Data versions.

enter image description here

I'm working with the DS.RESTAdapter calling for a /places this way:

this.store.findAll('place');

The model only have a name attribute name: DS.attr('string') The JSON is the following:

{
  places: [
    {
      id: 1,
      name: "San Francisco"
    },
    {
      id: 2,
      name: "Havana"
    }
  ]
}

I made the template and with the corresponding each and everything shows up and works so far but i get a deprecation warnings that tells the following:

DEPRECATION: The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "destination" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in your adapter:application and return true.

I don't know exactly what's the best approach to solve this warning. I'm new to ember so any further explanation will be fine. Thanks in advance.

like image 850
Javier Cadiz Avatar asked Jun 24 '15 02:06

Javier Cadiz


1 Answers

To comply with the new default behavior, override shouldReloadAll like this:

function shouldReloadAll( store, snapshot ) {
    return !store.peekAll( snapshot.type.modelName ).length
}
like image 172
Knucklehead Avatar answered Sep 22 '22 02:09

Knucklehead