"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 __()); }; /// var plugins = require("./taskbuffer.plugins"); var taskbuffer_classes_1 = require("./taskbuffer.classes"); var Taskchain = (function (_super) { __extends(Taskchain, _super); function Taskchain(taskArrayArg) { var _this = this; _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(); } }); } Taskchain.prototype.addTask = function (taskArg) { this.taskArray.push(taskArg); }; ; Taskchain.prototype.removeTask = function (taskArg) { //TODO }; ; Taskchain.prototype.shiftTask = function () { }; ; return Taskchain; }(taskbuffer_classes_1.Task)); exports.Taskchain = Taskchain; ; var myTask = new Taskchain(new taskbuffer_classes_1.Task({ taskFunction: function () { } })); //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsNENBQTRDO0FBQzVDLElBQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsbUNBQW1CLHNCQUFzQixDQUFDLENBQUE7QUFHMUM7SUFBK0IsNkJBQUk7SUFHL0IsbUJBQVksWUFBd0I7UUFIeEMsaUJBNEJDO1FBeEJPLGtCQUFNO1lBQ0YsWUFBWSxFQUFFO2dCQUNWLEVBQUUsQ0FBQSxDQUFDLEtBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQztvQkFBQyxNQU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AgICAgICAgICAgICAgICBwcm9taXNlUG9pbnRlci50aGVuKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlUG9pbnRlciA9IHRoaXMudGFza0FycmF5W2tleUFyZ10udHJpZ2dlcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByb21pc2VQb2ludGVyO1xuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgc3RhcnREZWZlcnJlZC5yZXNvbHZlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBhZGRUYXNrKHRhc2tBcmc6VGFzayl7XG4gICAgICAgIHRoaXMudGFza0FycmF5LnB1c2godGFza0FyZyk7XG4gICAgfTtcbiAgICByZW1vdmVUYXNrKHRhc2tBcmc6VGFzayl7XG4gICAgICAgIC8vVE9ET1xuICAgIH07XG4gICAgc2hpZnRUYXNrKCl7XG4gICAgICAgIFxuICAgIH07XG59O1xuXG5sZXQgbXlUYXNrID0gbmV3IFRhc2tjaGFpbihcbiAgICBuZXcgVGFzayh7XG4gICAgICAgIHRhc2tGdW5jdGlvbjpmdW5jdGlvbigpe31cbiAgICB9KVxuKTsiXX0=