Results 1 to 3 of 3

Thread: Custom proxy that re-routes to LocalStorage proxy and REST proxy internally

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    26
    Vote Rating
    2
      0  

    Default 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?

    Many thanks!

    Regards, Fei

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,412
    Vote Rating
    1288
      0  

    Default

    What framework and version are you using?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    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 services@sencha.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.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    26
    Vote Rating
    2
      0  

    Default

    Sencha Touch 2.0.1.1

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •