Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha Touch 2 MVC - How to implement and use a custom proxy

I've exactly the same problem from this Question. However I'm using Sencha Touch 2 and I don't know how to actually use this custom store. I define my REST proxies inside the model classes. How would I access/use this custom proxy?

proxy: {
    type: 'rest',
    url: 'http://someUrl', 
    reader: {
        type: 'json',
    }
}
like image 433
karazy Avatar asked Dec 27 '22 07:12

karazy


1 Answers

It is fairly simple in Sencha Touch 2. This presumes you have an MVC architecture.

Firstly, you model - app/model/Image.js:

Ext.define('MyApp.model.Image', {
    extend: 'Ext.data.Model',

    // Require your custom proxy
    requires: ['MyApp.proxy.MyCustomProxy'],

    config: {
        fields: ['name'],

        proxy: {
            // set the type of your proxy
            type: 'mycustomproxy'
        }
    }
});

And then define your proxy - app/proxy/MyCustomProxy.js:

Ext.define('MyApp.proxy.MyCustomProxy', {
    extend: 'Ext.data.proxy.Proxy',

    // Set your proxy alias
    alias: 'proxy.mycustomproxy',

    ...
});
like image 174
rdougan Avatar answered Apr 26 '23 07:04

rdougan