Created
March 7, 2012 10:24
-
-
Save slikts/1992412 to your computer and use it in GitHub Desktop.
Ext JS Observable Method Events
This file contains 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
(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