Skip to content

Instantly share code, notes, and snippets.

@acnalesso
Last active August 29, 2015 14:11
Show Gist options
  • Save acnalesso/6baa485787a981bbe285 to your computer and use it in GitHub Desktop.
Save acnalesso/6baa485787a981bbe285 to your computer and use it in GitHub Desktop.
deferred_queue_actions#flush example
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.'); });
});
});
// OUTPUTS
flushing sync
actions
actions schedduled in sync queue.
// WHILE LOOP ORDER
Queue {name: "sync", globalOptions: Object, options: undefined, _queue: Array[4], targetQueues: Object…}
Queue {name: "sync", globalOptions: Object, options: undefined, _queue: Array[0], targetQueues: Object…}
Queue {name: "actions", globalOptions: Object, options: undefined, _queue: Array[8], targetQueues: Object…}
Queue {name: "sync", globalOptions: Object, options: undefined, _queue: Array[0], targetQueues: Object…}
Queue {name: "actions", globalOptions: Object, options: undefined, _queue: Array[0], targetQueues: Object…}
Queue {name: "destroy", globalOptions: Object, options: undefined, _queue: Array[0], targetQueues: Object…}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment