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
var bb = new Backburner(['cook', 'prepare', 'serve']); | |
var food = { name: "" }; | |
function cookFood(name) { | |
console.log(name); | |
food.name = name; | |
} | |
function prepareFood() { | |
console.log('A chef is preparing your food!!!') |
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
invoke: function(target, method, args, _, _errorRecordedForStack) { | |
if (args && args.length > 0) { | |
method.apply(target, args); | |
} else { | |
method.call(target); | |
} | |
} |
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
invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { | |
try { | |
if (args && args.length > 0) { | |
method.apply(target, args); | |
} else { | |
method.call(target); | |
} | |
} catch(error) { | |
onError(error, errorRecordedForStack); | |
} |
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
test("Queue#flush should be recursive if new items are added", function() { | |
expect(2); | |
var bb = new Backburner(['one']); | |
var count = 0; | |
bb.run(function(){ | |
function increment() { | |
if (++count < 3) { | |
bb.schedule('one', increment); |
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; |
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
Ember.run(function() { | |
Ember.run.schedule('destroy', function() { | |
Ember.run.schedule('actions', function() { console.log('actions'); }); | |
Ember.run.schedule('sync', function() { console.log('sync'); }); | |
}); | |
}); | |
// sync | |
// actions | |
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
var b = new Backburner(['sync', 'actions', 'destroy'], { ... }); | |
b.run(function() { | |
b.schedule('actions', function() { console.log('actions'); }); | |
b.schedule('sync', function() { | |
console.log('flushing sync'); | |
b.schedule('actions', function() { console.log('actions schedduled in sync queue.'); }); | |
}); |
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: function() { | |
var queues = this.queues; | |
var queueNames = this.queueNames; | |
var queueName, queue, queueItems, priorQueueNameIndex; | |
var queueNameIndex = 0; | |
var numberOfQueues = queueNames.length; | |
var options = this.options; | |
while(queueNameIndex < numberOfQueues) { | |
queueName = queueNames[queueNameIndex]; |
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
end: function() { | |
var options = this.options; | |
var onEnd = options && options.ondEnd; | |
var currentInstance = this.currentInstance; | |
var nextInstance = null; | |
var finallyAlreadyCalled = false; | |
try { | |
currentInstance.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
run: function(target, method, /* options, arguments */) { | |
var onError = getOnError(this.options); | |
this.begin(); | |
if (!method) { | |
method = target; | |
target = null; | |
} | |
NewerOlder