5 Sep 2012 6:20 AM #1
Custom proxy that re-routes to LocalStorage proxy and REST proxy internally
My goal is to use LocalStorage as a cache and offline storage, and to use REST proxy as the online source. When data is fetched from the REST proxy, a copy is sent to the LocalStorage proxy.
Where is the best implementation point you would suggest?
Option 1: Implement a BaseModel with CRUD methods that does the routing.
Option 2: Implement a custom Store that does the routing.
Option 3: Implement a custom Proxy that does the routing.
I'm attempting Option 3 and extending from Proxy, but got an exception with 'Uncaught TypeError: Cannot call method 'getIdProperty' of null'. I guess it's related to the Model being null. Should I extend from DirectProxy instead? Or should I go with alternative options?
5 Sep 2012 7:10 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
What framework and version are you using?
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services email@example.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
5 Sep 2012 7:29 AM #3
Sencha Touch 18.104.22.168
I just made some progress. I resolved the exception by assigning model manually to the REST proxy, the LocalStorage proxy, and my custom Auto proxy.
Before, the model did not need to be assigned to proxy explicitly. By looking at your source code, I found it was automatically assigned when creating the store. Since now my store binds to the custom Auto proxy, I have to manually assign the model to the REST proxy and the LocalStorage proxy to eliminate the exception.
Am I on the right track? Any hint or sample implementation that you could provide? This requirement does not look to me as something too unusual. Thanks.