|
-
- // Subscribe several functions in a single call.
- Reporter.prototype.subscribeMany = function(funcs)
- {
- for (var i = 0; i < funcs.length; ++i)
- {
- var func = funcs[i];
- this.subscribe(func);
- }
- }
-
- murom.getMany = function(items, completionCallback)
- {
- var self = this;
- var results = {};
-
- var count = 0;
- function reportCompletion()
- {
- if (++count == items.length)
- {
- if (completionCallback)
- {
- completionCallback(results);
- }
- }
- }
-
- for (var id in items)
- {
- const item = items[id];
- const url = item[0];
- const name = item[1];
- var isBinary = (item[2] == "b");
-
- function success(contents)
- {
- results[name] = contents;
- reportCompletion()
- }
- function failure(status)
- {
- LOG(
- formatString(
- "ERROR Could not download URL: '{0}' status: '{1}'",
- url,
- status
- )
- );
- reportCompletion()
- }
-
- if (isBinary)
- {
- murom.getb(url, success, failure);
- }
- else
- {
- murom.get(url, success, failure);
- }
- }
- };
|