emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

why dose store.find always request server? #9357

Closed ghost closed 10 years ago

ghost commented 10 years ago

in user-route.js is:

...
model: function(){
  return this.store.find('user');
}
...

Ary time i select the user route, it always request server, why it doesn't save in store after the first successful request?

rwjblue commented 10 years ago

@luoguanzhong - This is more of a question for Stack Overflow. Please feel free to cross-link back here.

martinthogersen commented 10 years ago

Just a quick note: http://emberjs.com/guides/models/finding-records/#toc_finding-all-records-of-a-type

You can use store.all to find all loaded records.

fivetanley commented 10 years ago

It should do a network request only on the first call to find if it is not already in the store. Please note: unless you are using the local storage or indexeddb adapter, the record will not be stored to the browser across page refreshes. Meaning that ember data's store gets cleared out between page refreshes, and you won't have access to the model anymore, meaning a network request.