Skip to content
Snippets Groups Projects
Commit 8dcc9f2b authored by pkupczyk's avatar pkupczyk
Browse files

SP-555 / BIS-366 : openbis.js - delete utilities.js files and use...

SP-555 / BIS-366 : openbis.js - delete utilities.js files and use openbis-action-deferrer.js - remove utilities.js

SVN: 28997
parent 37888d18
No related branches found
No related tags found
No related merge requests found
/**
* 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.
* @class
*/
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.
* @method
*/
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