Created
August 29, 2014 20:57
-
-
Save MatthaeusHarris/a8a110a6d799a0be9664 to your computer and use it in GitHub Desktop.
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 eventAccumulator = function(event, eventsList, queue, callback) { | |
// logger.log("arena","eventAccumulator(%s,%s,%s,callback)",event, JSON.stringify(eventsList), JSON.stringify(queue)); | |
logger.log("arena","eventAccumulator queue: " + queue + " event: " + event); | |
if (typeof eventAccumulator[queue] === 'undefined' || typeof eventAccumulator[queue].eventList === 'undefined') { | |
eventAccumulator[queue] = {}; | |
eventAccumulator[queue].eventList = []; | |
for (var i in eventsList) { | |
eventAccumulator[queue].eventList.push(eventsList[i]) | |
} | |
} | |
eventAccumulator[queue].eventList = _.without(eventAccumulator[queue].eventList, event); | |
logger.log("arena","Still waiting for events: " + JSON.stringify(eventAccumulator[queue].eventList)); | |
if (eventAccumulator[queue].eventList.length == 0) { | |
delete(eventAccumulator[queue]); | |
logger.log("arena","Calling callback for queue " + queue); | |
callback(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment