taskbuffer/dist/taskbuffer.classes.taskchain.js

54 lines
5.1 KiB
JavaScript
Raw Normal View History

2016-05-04 02:28:50 +00:00
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/// <reference path="./typings/main.d.ts" />
var plugins = require("./taskbuffer.plugins");
2016-05-04 02:28:50 +00:00
var classes = require("./taskbuffer.classes");
var Taskchain = (function (_super) {
__extends(Taskchain, _super);
function Taskchain(taskArrayArg) {
var _this = this;
2016-05-04 02:28:50 +00:00
_super.call(this, {
taskFunction: function () {
if (_this.taskArray.length = 0)
return; //make sure there is actually a Task available to execute
var startDeferred = plugins.Q.defer(); // this is the starting Deferred object
var promisePointer = startDeferred.promise;
var _loop_1 = function(keyArg) {
promisePointer.then(function () {
promisePointer = this.taskArray[keyArg].trigger();
return promisePointer;
});
};
for (var keyArg in _this.taskArray) {
_loop_1(keyArg);
}
;
startDeferred.resolve();
}
2016-05-04 02:28:50 +00:00
});
}
Taskchain.prototype.addTask = function (taskArg) {
this.taskArray.push(taskArg);
};
;
Taskchain.prototype.removeTask = function (taskArg) {
//TODO
};
;
Taskchain.prototype.shiftTask = function () {
};
;
2016-05-04 02:28:50 +00:00
return Taskchain;
}(classes.Task));
exports.Taskchain = Taskchain;
;
var myTask = new Taskchain(new classes.Task({
taskFunction: function () { }
}));
2016-05-04 02:28:50 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsNENBQTRDO0FBQzVDLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsSUFBWSxPQUFPLFdBQU0sc0JBQ3pCLENBQUMsQ0FE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BhdmFpbGFibGUgdG8gZXhlY3V0ZVxuICAgICAgICAgICAgICAgIGxldCBzdGFydERlZmVycmVkID0gcGx1Z2lucy5RLmRlZmVyKCk7IC8vIHRoaXMgaXMgdGhlIHN0YXJ0aW5nIERlZmVycmVkIG9iamVjdCBcbiAgICAgICAgICAgICAgICBsZXQgcHJvbWlzZVBvaW50ZXIgPSBzdGFydERlZmVycmVkLnByb21pc2U7XG4gICAgICAgICAgICAgICAgZm9yKGxldCBrZXlBcmcgaW4gdGhpcy50YXNrQXJyYXkpe1xuICAgICAgICAgICAgICAgICAgICBwcm9taXNlUG9pbnRlci50aGVuKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlUG9pbnRlciA9IHRoaXMudGFza0FycmF5W2tleUFyZ10udHJpZ2dlcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByb21pc2VQb2ludGVyO1xuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgc3RhcnREZWZlcnJlZC5yZXNvbHZlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBhZGRUYXNrKHRhc2tBcmc6Y2xhc3Nlcy5UYXNrKXtcbiAgICAgICAgdGhpcy50YXNrQXJyYXkucHVzaCh0YXNrQXJnKTtcbiAgICB9O1xuICAgIHJlbW92ZVRhc2sodGFza0FyZzpjbGFzc2VzLlRhc2spe1xuICAgICAgICAvL1RPRE9cbiAgICB9O1xuICAgIHNoaWZ0VGFzaygpe1xuICAgICAgICBcbiAgICB9O1xufTtcblxubGV0IG15VGFzayA9IG5ldyBUYXNrY2hhaW4oXG4gICAgbmV3IGNsYXNzZXMuVGFzayh7XG4gICAgICAgIHRhc2tGdW5jdGlvbjpmdW5jdGlvbigpe31cbiAgICB9KVxuKTsiXX0=