Threaded View

  1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,507
    Vote Rating
    254
    LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of

      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