Skip to content

Instantly share code, notes, and snippets.

View AlexGach's full-sized avatar

Alex GaCh AlexGach

View GitHub Profile
@maxpeterson
maxpeterson / gist:6116613
Created July 30, 2013 20:28
Queue to ensure that functions are not called concurrently. Created to wrap Veeva API calls that can not be called concurrently.
// The Veeva API can only accept one call at a time.
// A queue is used to avoid calling the API while an earlier call is in progress.
var Queue = (function () {
var queue = [];
var empty = true;
return {
// Add a function to the queue
// (it will be called immediately if the queue is empty)
push: function (fn) {
queue.push(fn);