Reputation: 11013
There are two ways to use proxies in extjs 4.1 (server proxies in my case), one can tie it to a model or tie it on a store.
I am a bit confused about the usage: What is the difference between tieing a proxy to a store, and tieing it to a model?
What situations would one use one way or the other?
Upvotes: 19
Views: 6530
Reputation: 11013
OK I found it in the documentation of sencha App Architecture Part 2
Use proxies for models:
It is generally good practice to do this as it allows you to load and save instances of this model without needing a store. Also, when multiple stores use this same model, you don’t have to redefine your proxy on each one of them.
Use proxies for stores:
In Ext JS 4, multiple stores can use the same data model, even if the stores will load their data from different sources. In our example, the Station model will be used by the SearchResults and the Stations store, both loading the data from a different location. One returns search results, the other returns the user’s favorite stations. To achieve this, one of our stores will need to override the proxy defined on the model.
Upvotes: 21
Reputation: 2364
I always use proxies on stores not on models. Do you have an example/use-case where you want to attach a proxy to a model? Usually I always declare a store and attach the proxy to it.
Regarding the examples on the sencha documentation, I'd say that this is the way it's meant to be (I guess ;-))
Upvotes: 0