Created
December 10, 2014 14:02
-
-
Save acnalesso/4e90d7b8ba47c59cedef to your computer and use it in GitHub Desktop.
Queue#flush
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
flush: { | |
var queue = this._queue; | |
var length = queue.length; | |
if (length == 0) { | |
return; | |
} | |
var globalOptions = this.globalOptions; | |
var options = this.options; | |
var before = options && options.before; | |
var after = options && options.after; | |
var onError = globalOptions.onError || (globalOptions.onErrorTarget && | |
globalOptions.onErrorTarget[globalOptions.onErrorMethod]); | |
var target, method, args, errorRecordedForStack; | |
var invoke = onError ? this.invokeWithOnError : this.invoke; | |
this.targetQueues = Object.create(null); | |
var queueItems = this._queueBeingFlushed = this._queue.slice(); | |
this._queue = []; | |
if (before) { | |
before(); | |
} | |
for (var i = 0; i < legnth; i += 4) { | |
target = queueItems[i]; | |
method = queueItems[i+1]; | |
args = queueItems[i+2]; | |
errorRecordedForStack = queueItems[i+3]; | |
if (isString(method)) { | |
invoke(target, method, args, onError, errorRecordedForStack); | |
} | |
} | |
if (after) { | |
after(); | |
} | |
this._queueBeingFlushed = undefined; | |
if (sync !== false && this._queue.length > 0) { | |
// check if new items have been added | |
this.flush(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment