-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ed6edb
commit afb8b66
Showing
5 changed files
with
60 additions
and
92 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
Y.soon accepts a callback function. The callback function will be called | ||
once in a future turn of the JavaScript event loop. If the function | ||
requires a specific execution context or arguments, wrap it with Y.bind. | ||
Y.soon returns an object with a cancel method. If the cancel method is | ||
called before the callback function, the callback function won't be | ||
called. | ||
@method soon | ||
@for YUI | ||
@param {Function} callbackFunction | ||
@return {Object} An object with a cancel method. If the cancel method is | ||
called before the callback function, the callback function won't be | ||
called. | ||
**/ | ||
function soon(callbackFunction) { | ||
var canceled; | ||
|
||
soon._asynchronizer(function () { | ||
// Some asynchronizers may provide their own cancellation | ||
// methods such as clearImmediate or clearTimeout but some | ||
// asynchronizers do not. For simplicity, cancellation is | ||
// entirely handled here rather than wrapping the other methods. | ||
// All asynchronizers are expected to always call this anonymous | ||
// function. | ||
if (!canceled) { | ||
callbackFunction(); | ||
} | ||
}); | ||
|
||
return { | ||
cancel: function () { | ||
canceled = 1; | ||
} | ||
}; | ||
} | ||
|
||
soon._asynchronizer = asap; | ||
|
||
Y.soon = soon; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Provides utilities for timed asynchronous callback execution. | ||
* Y.soon is a setImmediate/process.nextTick/setTimeout wrapper. | ||
* | ||
* @module timers | ||
* @author Steven Olmsted | ||
*/ | ||
var module = {}, | ||
global = Y.config.global; | ||
|
||
function require(mod) { | ||
return Queue; | ||
} |
This file was deleted.
Oops, something went wrong.