1. #1
    Sencha Premium Member
    Join Date
    Aug 2010
    Location
    Quebec, Canada
    Posts
    10
    Vote Rating
    0
    jracine is on a distinguished road

      0  

    Default Ext.direct.PollingProvider in MVC architecture

    Ext.direct.PollingProvider in MVC architecture


    I used a Ext.direct.PollingProvider in Ext JS 4, it works great, but now I try to put my code in MVC architecture and I don't know how to add listeners to the Ext.directPollingProvider.

    Here's my code in Ext Js 4:

    Code:
    var poll = new Ext.direct.PollingProvider({
        type:'polling',
        url: 'deliveries/getProgression',
        id:  'poll',
        interval: 10000,
        listeners: {
            beforepoll: function( p ) {
                console.log(p);
            },
            data: function( provider, event ) {
                Ext.each(event.data, function( el ){ 
                    console.log(el.id);
                });
            }
        }
    });
        
    Ext.direct.Manager.addProvider(NL.REMOTING_API, poll);
    In MVC architecture, I define the pollingProvider in a view. I'm not sure that is the best method. Here's my code of the view:

    Code:
    Ext.define('NL.view.polling', {
             extend: 'Ext.direct.PollingProvider',
             alias: 'widget.poll',
             type:'polling',
             url: 'deliveries/getProgression',
             id:  'poll',
             interval: 10000
    });
    In the controller, I try to call the event beforepoll and data in the init function, but it doesn't work. Here's an example of my controller:

    Code:
    Ext.define('NL.controller.Main', {
             extend: 'Ext.app.Controller',
             views: ['Polling']
    
             init: function() {
                      this.control({
                             'poll': {
                                     beforepoll: this.beforePolling, 
                                     data: this.applyData  
                             }
                      })
             },
        
             beforePolling: function() {
                     console.log('action before polling');
             },
        
             applyData: function() {
                     console.log('apply data');    
             }
    });
    Here's a part of my file app.js
    Code:
    controllers: ['Main'],
    
    launch: function() {
             var poll = Ext.widget('poll');
             Ext.direct.Manager.addProvider(NL.REMOTING_API, poll);    
    }
    What would be the best way to include a Ext.direct.PollingProvider in MVC architecture. Thanks for your help.

  2. #2
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,657
    Vote Rating
    5
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    Maybe have a look to my workshop demo where i also use the polling provider
    http://dev.sk-typo3.de/ext4/workshop/

    You have to know that polling starts right after adding the provider. if you want that programmatically, you have to disconnect the provider right after adding.
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2010
    Location
    Quebec, Canada
    Posts
    10
    Vote Rating
    0
    jracine is on a distinguished road

      0  

    Default


    Thanks for your demo.
    It helped me a lot.

  4. #4
    Sencha Premium Member richardvd's Avatar
    Join Date
    Jun 2011
    Location
    NL
    Posts
    43
    Vote Rating
    12
    richardvd will become famous soon enough

      0  

    Default broken link

    broken link


    Quote Originally Posted by steffenk View Post
    Maybe have a look to my workshop demo where i also use the polling provider
    http://dev.sk-typo3.de/ext4/workshop/
    Steffen, the link is broken. Although a few years have passed, I think it is still relevant and I would like to see the code of this workshop. Is it still online somewhere?
    Richard

Thread Participants: 2