X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/docs/api/Ext.util.DelayedTask.html diff --git a/docs/api/Ext.util.DelayedTask.html b/docs/api/Ext.util.DelayedTask.html new file mode 100644 index 00000000..64e430bd --- /dev/null +++ b/docs/api/Ext.util.DelayedTask.html @@ -0,0 +1,86 @@ +Ext.util.DelayedTask | Ext JS 4.0 Documentation +
For up to date documentation and features, visit +http://docs.sencha.com/ext-js/4-0

Sencha Documentation

+ + + + + +

The DelayedTask class provides a convenient way to "buffer" the execution of a method, +performing setTimeout where a new timeout cancels the old timeout. When called, the +task will wait the specified time period before executing. If durng that time period, +the task is called again, the original call will be cancelled. This continues so that +the function is only called a single time for each iteration.

+ +

This method is especially useful for things like detecting whether a user has finished +typing in a text field. An example would be performing validation on a keypress. You can +use this class to buffer the keypress events for a certain number of milliseconds, and +perform only if they stop for that amount of time.

+ +

Usage

+ +
var task = new Ext.util.DelayedTask(function(){
+    alert(Ext.getDom('myInputField').value.length);
+});
+
+// Wait 500ms before calling our function. If the user presses another key
+// during that 500ms, it will be cancelled and we'll wait another 500ms.
+Ext.get('myInputField').on('keypress', function(){
+    task.delay(500);
+});
+
+ +

Note that we are using a DelayedTask here to illustrate a point. The configuration +option buffer for addListener/on will +also setup a delayed task for you to buffer events.

+
Defined By

Methods

 
DelayedTask( +[Function fn], Object scope, [Array args]) + : void

The parameters to this constructor serve as defaults and are not required.

+

The parameters to this constructor serve as defaults and are not required.

+

Parameters

  • fn : Function

    (optional) The default function to call.

    +
  • scope : Object

    The default scope (The this reference) in which the +function is called. If not specified, this will refer to the browser window.

    +
  • args : Array

    (optional) The default Array of arguments.

    +

Returns

  • void    +
 

Cancel the last queued timeout

+

Cancel the last queued timeout

+

Returns

  • void    +
 
delay( +Number delay, [Function newFn], [Object newScope], [Array newArgs]) + : void

Cancels any pending timeout and queues a new one

+

Cancels any pending timeout and queues a new one

+

Parameters

  • delay : Number

    The milliseconds to delay

    +
  • newFn : Function

    (optional) Overrides function passed to constructor

    +
  • newScope : Object

    (optional) Overrides scope passed to constructor. Remember that if no scope +is specified, this will refer to the browser window.

    +
  • newArgs : Array

    (optional) Overrides args passed to constructor

    +

Returns

  • void    +
\ No newline at end of file