Skip to content

Instantly share code, notes, and snippets.

@4z3
Created January 21, 2011 23:01
Show Gist options
  • Save 4z3/790604 to your computer and use it in GitHub Desktop.
Save 4z3/790604 to your computer and use it in GitHub Desktop.
Temporary queue up messages
// Temporary publish() to queue up messages until connection to Genericore
// is ready.
var publish_queue = [];
var publish_enqueue = function (message) {
publish_queue.push(message);
log('enqueue: ' + publish_queue.length);
};
var publish = publish_enqueue;
var ready = function (client) {
// bind real publish function and flush publish_queue to Genericore.
publish = client.publish;
for (var i = 0; i < publish_queue.length; ++i) {
log('dequeue: ' + i + '/' + publish_queue.length);
publish(publish_queue[i]);
};
publish_queue = [];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment