Skip to content

Instantly share code, notes, and snippets.

@acnalesso
Created December 2, 2014 17:56
Show Gist options
  • Save acnalesso/7ffabea06d503f81ffab to your computer and use it in GitHub Desktop.
Save acnalesso/7ffabea06d503f81ffab to your computer and use it in GitHub Desktop.
backburner end
end: function() {
var options = this.options;
var onEnd = options && options.ondEnd;
var currentInstance = this.currentInstance;
var nextInstance = null;
var finallyAlreadyCalled = false;
try {
currentInstance.flush();
} finally {
if (!finallyAlreadyCalled) {
finallyAlreadyCalled = true;
this.currentInstance = null;
if (this.instanceStack.length) {
nextInstance = this.instanceStack.pop();
this.currentInstance = nextInstance;
}
if (onEnd) {
onEnd(currentInstance, nextInstance)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment