Colin
Colin

Reputation: 1855

Use of Proxies in ExtJS

I'm a little confused after reading some of Sencha's doc's.

From what I've read, ExtJS places proxies between models/stores and client/server. Now, say I have a store that needs to load data that could be located in a local cache, or HTML5-LocalStorage, and if not needs to GET from a server. Do I configure a single proxy that manages this (which, in my opinion is a nice, clean, separation of concerns), or separate proxies per source.

Any clarification is apprecaited

Upvotes: 0

Views: 118

Answers (1)

Jeff Shaver
Jeff Shaver

Reputation: 3355

The best way to probably do this is to not auto-load the store. Do the logic seperate from the proxy. Check whether the data is in local cache or HTML 5 Storage. If it is, load that data using loadData. If it is neither of those, tell the store to load itself, therefore, using the proxy set up on the store. This means you will only have 1 Store and 1 Proxy.

if (dataIsInLocalCache) {
    store.loadData(dataFromLocalCache);
} else if (dataisInHTML5Storage) {
    store.loadData(dataFromHTMLStorage);
} else {
    store.load();
}

Upvotes: 2

Related Questions