YUI recommends YUI 3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

Yahoo! UI Library

DataTable Widget  2.5.0

Yahoo! UI Library > datatable > YAHOO.util.Chain

Show Private Show Protected

Class YAHOO.util.Chain

Mechanism to execute a series of callbacks in a non-blocking queue. Each callback is executed via setTimout unless configured with a negative timeout, in which case it is run in blocking mode in the same execution thread as the previous callback. Callbacks can be function references or object literals with the following keys:
  • method - {Function} REQUIRED the callback function.
  • scope - {Object} the scope from which to execute the callback. Default is the global window scope.
  • argument - {Array} parameters to be passed to method as individual arguments.
  • timeout - {number} millisecond delay to wait after previous callback completion before executing this callback. Negative values cause immediate blocking execution. Default 0.
  • until - {Function} boolean function executed before each iteration. Return true to indicate completion and proceed to the next callback.
  • iterations - {Number} number of times to execute the callback before proceeding to the next callback in the chain. Incompatible with until.


YAHOO.util.Chain ( callback* )
callback* <Function|Object> Any number of callbacks to initialize the queue


id - private {number}

Timeout id used to pause or stop execution and indicate the execution state of the Chain. 0 indicates paused or stopped, -1 indicates blocking execution, and any positive number indicates non-blocking execution.

q - private {Array}

The callback queue



Chain add ( c )
Add a callback to the end of the queue
c <Function|Object> the callback function ref or object literal
Returns: Chain
the Chain instance


Chain pause ( )
Pause the execution of the Chain after the current execution of the current callback completes. If called interstitially, clears the timeout for the pending callback. Paused Chains can be restarted with chain.run()
Returns: Chain
the Chain instance


Chain run ( )
Begin executing the chain, or resume execution from the last paused position.
Returns: Chain
the Chain instance


Chain stop ( )
Stop and clear the Chain's queue after the current execution of the current callback completes.
Returns: Chain
the Chain instance

Copyright © 2007 Yahoo! Inc. All rights reserved.