methodName
of object
.
Note that the execution scope will still be bound to the provided object
itself.fn
, change this
to the provided scope, optionally
overrides arguments for the call. (Defaults to the arguments passed by the caller)this
reference) in which the function is executed.
If omitted, defaults to the browser window.Creates a delegate function, optionally with a bound scope which, when called, buffers the execution of the passed function for the configured number of milliseconds. If called again within that period, the impending invocation will be canceled, and the timeout period will begin again.
The resulting function is also an instance of Ext.util.DelayedTask, and so
therefore implements the cancel
and
delay
methods.
this
reference) in which
the passed function is executed. If omitted, defaults to the scope specified by the caller.var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
// create a new function that validates input without
// directly modifying the original function:
var sayHiToFriend = Ext.Function.createInterceptor(sayHi, function(name){
return name == 'Brian';
});
sayHiToFriend('Fred'); // no alert
sayHiToFriend('Brian'); // alerts "Hi, Brian"
this
reference) in which the passed function is executed.
If omitted, defaults to the scope in which the original function is called or the browser window.var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
var sayGoodbye = Ext.Function.createSequence(sayHi, function(name){
alert('Bye, ' + name);
});
sayGoodbye('Fred'); // both alerts show
Creates a throttled version of the passed function which, when called repeatedly and rapidly, invokes the passed function only after a certain interval has elapsed since the previous invocation.
This is useful for wrapping functions which may be called repeatedly, such as a handler of a mouse move event when the processing is expensive.
this
reference) in which
the passed function is executed. If omitted, defaults to the scope specified by the caller.var sayHi = function(name){
alert('Hi, ' + name);
}
// executes immediately:
sayHi('Fred');
// executes after 2 seconds:
Ext.Function.defer(sayHi, 2000, this, ['Fred']);
// this syntax is sometimes useful for deferring
// execution of an anonymous function:
Ext.Function.defer(function(){
alert('Anonymous');
}, 100);
this
reference) in which the function is executed.
If omitted, defaults to the browser window.name
and value
.
The wrapped function then allows "flexible" value setting of either:
name
and value
as 2 argumentsvar setValue = Ext.Function.flexSetter(function(name, value) {
this[name] = value;
});
// Afterwards
// Setting a single name - value
setValue('name1', 'value1');
// Settings multiple name - value pairs
setValue({
name1: 'value1',
name2: 'value2',
name3: 'value3'
});
Ext.pass(myFunction, arg1, arg2)
Will create a function that is bound to those 2 args. If a specific scope is required in the
callback, use Ext.Function.bind instead. The function returned by 'pass' always
executes in the window scope.
This method is required when you want to pass arguments to a callback function. If no arguments are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn). However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function would simply execute immediately when the code is parsed. Example usage:
var sayHi = function(name){
alert('Hi, ' + name);
}
// clicking the button alerts "Hi, Fred"
new Ext.Button({
text: 'Say Hi',
renderTo: Ext.getBody(),
handler: Ext.pass(sayHi, 'Fred')
});