Created
January 25, 2013 02:07
-
-
Save mitchellsimoens/4631086 to your computer and use it in GitHub Desktop.
suspendEvents/resumeEvents for ST 2 (will be part of 2.2.0 b1).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('Override.mixin.Observable', { | |
override : 'Ext.mixin.Observable', | |
eventFiringSuspended : false, | |
doFireEvent : function (eventName, args, action, connectedController) { | |
var me = this, | |
ret = true, | |
eventQueue; | |
if (me.eventFiringSuspended) { | |
eventQueue = me.eventQueue; | |
if (!eventQueue) { | |
me.eventQueue = eventQueue = []; | |
} | |
eventQueue.push([eventName, args, action, connectedController]); | |
} else { | |
ret = me.getEventDispatcher().dispatchEvent(me.observableType, me.getObservableId(), eventName, args, action, connectedController); | |
} | |
return ret; | |
}, | |
/** | |
* Suspends the firing of all events. | |
* | |
* All events will be queued but you can discard the queued events by passing true in | |
* the {@link #resumeEvents} call | |
*/ | |
suspendEvents : function () { | |
this.eventFiringSuspended = true; | |
}, | |
/** | |
* Resumes firing events (see {@link #suspendEvents}). | |
* | |
* @param {Boolean} discardQueuedEvents Pass as true to discard any queued events. | |
*/ | |
resumeEvents : function (discardQueuedEvents) { | |
var me = this, | |
eventQueue = me.eventQueue || [], | |
i, ln; | |
//resume the events | |
me.eventFiringSuspended = false; | |
//don't loop over the queue if specified to discard the queue | |
if (!discardQueuedEvents) { | |
for (i = 0, ln = eventQueue.length; i < ln; i++) { | |
me.doFireEvent.apply(me, eventQueue[i]); | |
} | |
} | |
//clear the queue | |
me.eventQueue = []; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment