1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,310
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default EventBus - suspending events

    EventBus - suspending events


    Here's a code fragment from my controller.

    I have a private method that sets a checkbox value. I want to suspend events on the checkobx so the change event is not fired. I tried to call suspendEvents on the checkbox, but this wasn't effective. Now I'm calling suspendEvents on the eventbus, and this is working for me. Am I doing it right?

    Also, looking at the EventBus code... I'm curious why the EventBus class is not a singleton since there's only one eventbus in an application.

    I probably don't fully understand the Ext.override feature, but why the Ext.app.EventBus class overrides the Ext.Component.fireEvent class as opposed to using the Ext.Function methods to create an interceptor?

    Code:
    Ext.define('StoreLayout.controller.ConfigViewController', {
        extend: 'Ext.app.Controller',
    
        ...
        // @private
        setCheckboxValue: function (checkbox, value) {
            var me = this,
                eventbus = me.application.eventbus,
            ...
            eventbus.suspendEvents();
            checkbox.setValue(value);
            eventbus.resumeEvents();
        },
        ...
    });
    ***EDIT
    >>> Now I'm calling suspendEvents on the eventbus, and this is working for me. Am I doing it right?

    After more testing, calling suspendEvents on the eventbus is not reliable. I guess I'm stuck. How do I suspend events in a controller?
    Last edited by LesJ; 15 Mar 2012 at 6:26 AM. Reason: Clarification about eventbuss.suspendEvents

  2. #2
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,310
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    Overriding fireEvent is a drastic solution. Now every fireEvent goes through the dispatch function. This doesn't look very efficient to me.

    Code:
    Ext.define('Ext.app.EventBus', {
        ...
        constructor: function() {
            this.mixins.observable.constructor.call(this);
    
            this.bus = {};
    
            var me = this;
            Ext.override(Ext.Component, {
                fireEvent: function(ev) {
                    if (Ext.util.Observable.prototype.fireEvent.apply(this, arguments) !== false) {
                        return me.dispatch.call(me, ev, this, arguments);
                    }
                    return false;
                }
            });
        },
        .....

  3. #3
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,310
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    The other point to consider is that the EventBus will now listen to events fired by all components, but controllers may control only certain (not all) views/components.

  4. #4
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,310
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    Quote Originally Posted by LesJ View Post
    Overriding fireEvent is a drastic solution. Now every fireEvent goes through the dispatch function. This doesn't look very efficient to me.

    Code:
    Ext.define('Ext.app.EventBus', {
        ...
        constructor: function() {
            this.mixins.observable.constructor.call(this);
    
            this.bus = {};
    
            var me = this;
            Ext.override(Ext.Component, {
                fireEvent: function(ev) {
                    if (Ext.util.Observable.prototype.fireEvent.apply(this, arguments) !== false) {
                        return me.dispatch.call(me, ev, this, arguments);
                    }
                    return false;
                }
            });
        },
        .....
    The fact that Ext.Component.fireEvent is overridden implies that only one application may exist on a page. I assume this is the usual case, but if I wanted to have multiple applications this would create problems. I think it should be possible to load and work with multiple applications. Do you see this as an issue?

  5. #5
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,310
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    Quote Originally Posted by LesJ View Post
    Also, looking at the EventBus code... I'm curious why the EventBus class is not a singleton since there's only one eventbus in an application.
    Heh... I see that the EventBus class is now a singleton in 4.2. Thx

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi