Skip to content
Snippets Groups Projects
Commit 56591eab authored by cramakri's avatar cramakri
Browse files

MINOR Use the official openbis.js

SVN: 25166
parent 897bf78e
No related branches found
No related tags found
No related merge requests found
......@@ -309,3 +309,35 @@ openbis.prototype.executeQuery = function(queryId, parameterBindings, action) {
success: action
});
}
/**
* A utility class for deferring an action until all of some kind of action has completed
*
* @argument dependencies An array of the keys for the dependencies.
*/
function actionDeferrer(pendingAction, dependencies) {
this.pendingAction = pendingAction;
this.dependencies = {};
var newme = this;
dependencies.forEach(function(key) {
newme.dependencies[key] = false;
});
}
/**
* Note that a dependency completed. Execute the pending action if appropriate.
*/
actionDeferrer.prototype.dependencyCompleted = function(key) {
this.dependencies[key] = true;
var shouldExecute = true;
for (prop in this.dependencies) {
if (false == this.dependencies[prop]) {
shouldExecute = false;
break;
}
}
if (shouldExecute) {
this.pendingAction();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment