53 lines
4.1 KiB
JavaScript
53 lines
4.1 KiB
JavaScript
"use strict";
|
|
// TaskChain chains tasks
|
|
// and extends Task
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const plugins = require("./taskbuffer.plugins");
|
|
const taskbuffer_classes_task_1 = require("./taskbuffer.classes.task");
|
|
class Taskchain extends taskbuffer_classes_task_1.Task {
|
|
constructor(optionsArg) {
|
|
let options = plugins.lodash.merge({
|
|
name: 'unnamed Taskchain',
|
|
log: false
|
|
}, optionsArg, {
|
|
taskFunction: (x) => {
|
|
let done = plugins.q.defer(); // this is the starting Deferred object
|
|
let taskCounter = 0; // counter for iterating async over the taskArray
|
|
let iterateTasks = (x) => {
|
|
if (typeof this.taskArray[taskCounter] !== 'undefined') {
|
|
this._oraObject.text(this.name + ' running: Task' + this.taskArray[taskCounter].name);
|
|
this.taskArray[taskCounter].trigger(x)
|
|
.then((x) => {
|
|
plugins.beautylog.ok(this.taskArray[taskCounter].name);
|
|
taskCounter++;
|
|
iterateTasks(x);
|
|
});
|
|
}
|
|
else {
|
|
this._oraObject.endOk('Taskchain "' + this.name + '" completed successfully');
|
|
done.resolve(x);
|
|
}
|
|
};
|
|
iterateTasks(x);
|
|
return done.promise;
|
|
}
|
|
});
|
|
super(options);
|
|
this.taskArray = optionsArg.taskArray;
|
|
this._oraObject = plugins.beautylog.ora;
|
|
if (optionsArg.log === true) {
|
|
this._oraObject.start();
|
|
}
|
|
}
|
|
addTask(taskArg) {
|
|
this.taskArray.push(taskArg);
|
|
}
|
|
removeTask(taskArg) {
|
|
// TODO:
|
|
}
|
|
shiftTask() {
|
|
// TODO:
|
|
}
|
|
}
|
|
exports.Taskchain = Taskchain;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2x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