1. #1
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    12
    Vote Rating
    0
    rclifton is on a distinguished road

      0  

    Default Store with a polling proxy?

    Store with a polling proxy?


    Hello,

    I'm trying to figure out how to build a proxy that polls the server and updates it's Store. I have a regular proxy working that will make a directFn call and update a store once. How can I do this on an interval?

    The examples seems to suggest that I should add a listener to the proxy that fires off a poll event. The listener would then grab the model and update the data. Seems plausible, however I just want to make sure that the easiest way to do this. Shouldn't there simply be a proxy type that will make a direct call on an interval and automatically update its Store?

    This works, once. I want it to run every X seconds until i tell it to stop.

    Code:
    Ext.define('MyApp.model.SummaryAppModel', {
        extend: 'Ext.data.Model',
    
        fields: ['name','type','value']
    });
    
    Ext.define('MyApp.store.SummaryAppStore', {
        extend: 'Ext.data.Store',
        requires: [
            'MyApp.model.SummaryAppModel'
        ],
    
        paramsAsHash: false,
        idProperty: 'value',
        storeId: 'SummaryAppStore',
        model: 'MyApp.model.SummaryAppModel',
        groupField: 'type',
        autoLoad: true,
        proxy: {
            type: 'direct',
            directFn: 'RTSStats.getAppStatsDirect'
        }
    });
    
    Ext.define('Ext.grid.RTSLeftPanel', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.rtsleftpanel',
        collapsible: false,
        iconCls: 'icon-grid',
        frame: true,
        store: 'SummaryAppStore',
        width: 200,
        resizable: false,
        features: [groupingLeftFeature],
        columns: [{
            text: 'Field',
            flex: 1,
            dataIndex: 'name'
        },{
            text: 'Value',
            flex: 1,
            dataIndex: 'value'
        },{
            text: 'Type',
            flex: 1,
            dataIndex: 'type'
        }]
    });

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,078
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I have used something like this before.

    Code:
        var buttonAuto = new Ext.Button({
            text: 'Set Interval',
            width: 150,
            renderTo: Ext.getBody(),
            handler: function() {
    
                var interval = setInterval(function() {
                    store.load();
                }, 6000); // refresh every 6 sec
            }
        });
    Regards,
    Scott.

Thread Participants: 1