Skip to content

Instantly share code, notes, and snippets.

@slikts
Created March 7, 2012 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slikts/1992412 to your computer and use it in GitHub Desktop.
Save slikts/1992412 to your computer and use it in GitHub Desktop.
Ext JS Observable Method Events
(function() {
// Private
function addMethodEvent(options) {
var method = this[options.method];
var event = (options.prefix ? options.prefix + '_' : '') + options.method;
function wrap() {
this.fireEvent(event + '_start', this, arguments);
this.fireEvent(event + '_end', this, arguments,
method.apply(this, arguments));
}
this[options.method] = wrap;
}
Ext.define('Common.mixins.MethodEvents', {
addMethodEvents: function() {
var options;
var argument;
for (var i = 0, n = arguments.length; i < n; i++) {
options = {
method: null,
prefix: ''
}
argument = arguments[i];
if (Ext.isString(argument)) {
options.method = argument;
} else {
Ext.apply(options, argument);
}
addMethodEvent.call(this, options);
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment