improve options handling between classes

This commit is contained in:
Philipp Kunz 2016-05-14 23:24:11 +02:00
parent 1f3f2ae92f
commit 454a999a42
10 changed files with 54 additions and 16 deletions

View File

@ -16,6 +16,7 @@ export declare class Task {
afterTask?: Task;
buffered?: boolean;
bufferMax?: number;
name?: string;
});
trigger(): any;
triggerUnBuffered(): any;

File diff suppressed because one or more lines are too long

View File

@ -2,8 +2,12 @@ import { Task } from "./taskbuffer.classes";
export declare class Taskchain extends Task {
taskArray: Task[];
private _oraObject;
constructor(taskArrayArg: Task[] | Task);
constructor(optionsArg: {
taskArray: Task[];
name?: string;
});
addTask(taskArg: Task): void;
removeTask(taskArg: Task): void;
shiftTask(): void;
trigger(): void;
}

View File

@ -9,9 +9,9 @@ var plugins = require("./taskbuffer.plugins");
var taskbuffer_classes_1 = require("./taskbuffer.classes");
var Taskchain = (function (_super) {
__extends(Taskchain, _super);
function Taskchain(taskArrayArg) {
function Taskchain(optionsArg) {
var _this = this;
_super.call(this, {
var options = plugins.lodash.assign(optionsArg, {
taskFunction: function () {
if (_this.taskArray.length = 0)
return; //make sure there is actually a Task available to execute
@ -30,6 +30,8 @@ var Taskchain = (function (_super) {
startDeferred.resolve();
}
});
_super.call(this, options);
this.taskArray = optionsArg.taskArray;
this._oraObject = plugins.beautylog.ora("Taskchain idle", "blue");
}
Taskchain.prototype.addTask = function (taskArg) {
@ -43,12 +45,19 @@ var Taskchain = (function (_super) {
Taskchain.prototype.shiftTask = function () {
};
;
Taskchain.prototype.trigger = function () {
this._oraObject.start(this.name + "running");
};
return Taskchain;
}(taskbuffer_classes_1.Task));
exports.Taskchain = Taskchain;
;
var myTask = new Taskchain(new taskbuffer_classes_1.Task({
taskFunction: function () { }
}));
var myTask = new Taskchain({
taskArray: [
new taskbuffer_classes_1.Task({
taskFunction: function () { }
})
]
});
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRhc2tidWZmZXIuY2xhc3Nlcy50YXNrY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+IHsgLy8gdGhpcyBpcyB0aGUgZnVuY3Rpb24gdGhhdCBnZXRzIGV4ZWN1dGVkIHdoZW4gVGFza0NoYWluIGlzIHRyaWdnZXJlZFxyXG4gICAgICAgICAgICAgICAgaWYodGhpcy50YXNrQXJyYXkubGVuZ3RoID0gMCkgcmV0dXJuOyAvL21ha2Ugc3VyZSB0aGVyZSBpcyBhY3R1YWxseSBhIFRhc2sgYXZhaWxhYmxlIHRvIGV4ZWN1dGVcclxuICAgICAgICAgICAgICAgIGxldCBzdGFydERlZmVycmVkID0gcGx1Z2lucy5RLmRlZmVyKCk7IC8vIHRoaXMgaXMgdGhlIHN0YXJ0aW5nIERlZmVycmVkIG9iamVjdCBcclxuICAgICAgICAgICAgICAgIGxldCBwcm9taXNlUG9pbnRlciA9IHN0YXJ0RGVmZXJyZWQucHJvbWlzZTtcclxuICAgICAgICAgICAgICAgIGZvcihsZXQga2V5QXJnIGluIHRoaXMudGFza0FycmF5KXtcclxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlUG9pbnRlci50aGVuKGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb21pc2VQb2ludGVyID0gdGhpcy50YXNrQXJyYXlba2V5QXJnXS50cmlnZ2VyKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm9taXNlUG9pbnRlcjtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgIHN0YXJ0RGVmZXJyZWQucmVzb2x2ZSgpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgdGhpcy5fb3JhT2JqZWN0ID0gcGx1Z2lucy5iZWF1dHlsb2cub3JhKFwiVGFza2NoYWluIGlkbGVcIixcImJsdWVcIik7XHJcbiAgICB9XHJcbiAgICBhZGRUYXNrKHRhc2tBcmc6VGFzayl7XHJcbiAgICAgICAgdGhpcy50YXNrQ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YWN0dWFsbHkgYSBUYXNrIGF2YWlsYWJsZSB0byBleGVjdXRlXHJcbiAgICAgICAgICAgICAgICBsZXQgc3RhcnREZWZlcnJlZCA9IHBsdWdpbnMuUS5kZWZlcigpOyAvLyB0aGlzIGlzIHRoZSBzdGFydGluZyBEZWZlcnJlZCBvYmplY3QgXHJcbiAgICAgICAgICAgICAgICBsZXQgcHJvbWlzZVBvaW50ZXIgPSBzdGFydERlZmVycmVkLnByb21pc2U7XHJcbiAgICAgICAgICAgICAgICBmb3IobGV0IGtleUFyZyBpbiB0aGlzLnRhc2tBcnJheSl7XHJcbiAgICAgICAgICAgICAgICAgICAgcHJvbWlzZVBvaW50ZXIudGhlbihmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9taXNlUG9pbnRlciA9IHRoaXMudGFza0FycmF5W2tleUFyZ10udHJpZ2dlcigpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWlzZVBvaW50ZXI7XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgICAgIH07XHJcbiAgICAgICAgICAgICAgICBzdGFydERlZmVycmVkLnJlc29sdmUoKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIHN1cGVyKG9wdGlvbnMpO1xyXG4gICAgICAgIHRoaXMudGFza0FycmF5ID0gb3B0aW9uc0FyZy50YXNrQXJyYXk7XHJcbiAgICAgICAgdGhpcy5fb3JhT2JqZWN0ID0gcGx1Z2lucy5iZWF1dHlsb2cub3JhKFwiVGFza2NoYWluIGlkbGVcIixcImJsdWVcIik7XHJcbiAgICB9XHJcbiAgICBhZGRUYXNrKHRhc2tBcmc6VGFzayl7XHJcbiAgICAgICAgdGhpcy50YXNrQXJyYXkucHVzaCh0YXNrQXJnKTtcclxuICAgIH07XHJcbiAgICByZW1vdmVUYXNrKHRhc2tBcmc6VGFzayl7XHJcbiAgICAgICAgLy9UT0RPXHJcbiAgICB9O1xyXG4gICAgc2hpZnRUYXNrKCl7XHJcbiAgICAgICAgXHJcbiAgICB9O1xyXG4gICAgdHJpZ2dlcigpe1xyXG4gICAgICAgIHRoaXMuX29yYU9iamVjdC5zdGFydCh0aGlzLm5hbWUgKyBcInJ1bm5pbmdcIik7XHJcbiAgICB9XHJcbn07XHJcblxyXG5sZXQgbXlUYXNrID0gbmV3IFRhc2tjaGFpbihcclxuICAgIHtcclxuICAgICAgICB0YXNrQXJyYXk6IFtcclxuICAgICAgICAgICAgbmV3IFRhc2soe1xyXG4gICAgICAgICAgICAgICAgdGFza0Z1bmN0aW9uOmZ1bmN0aW9uKCl7fVxyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgIF1cclxuICAgIH1cclxuKTsiXX0=

View File

@ -1,2 +1,3 @@
export import beautylog = require("beautylog");
export declare let Q: any;
export declare let lodash: any;

View File

@ -2,5 +2,6 @@
/// <reference path="./typings/main.d.ts" />
exports.beautylog = require("beautylog");
exports.Q = require("q");
exports.lodash = require("lodash");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRhc2tidWZmZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsNENBQTRDO0FBQzlCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDcEMsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyIsImZpbGUiOiJ0YXNrYnVmZmVyLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XHJcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcclxuZXhwb3J0IGxldCBRID0gcmVxdWlyZShcInFcIik7XHJcbiJdfQ==
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRhc2tidWZmZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsNENBQTRDO0FBQzlCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDcEMsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNqQixjQUFNLEdBQUUsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDIiwiZmlsZSI6InRhc2tidWZmZXIucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cclxuZXhwb3J0IGltcG9ydCBiZWF1dHlsb2cgPSByZXF1aXJlKFwiYmVhdXR5bG9nXCIpO1xyXG5leHBvcnQgbGV0IFEgPSByZXF1aXJlKFwicVwiKTtcclxuZXhwb3J0IGxldCBsb2Rhc2g9IHJlcXVpcmUoXCJsb2Rhc2hcIik7XHJcbiJdfQ==

View File

@ -24,6 +24,7 @@
"homepage": "https://github.com/pushrocks/taskbuffer#readme",
"dependencies": {
"beautylog": "^4.2.0",
"lodash": "^4.12.0",
"projectinfo": "1.0.1",
"q": "^1.4.1",
"rx": "^4.1.0"

View File

@ -2,7 +2,6 @@
import * as plugins from "./taskbuffer.plugins"
import * as helpers from "./taskbuffer.classes.helpers"
export class Task {
name:string;
task:any;
@ -16,7 +15,14 @@ export class Task {
preTask:Task;
afterTask:Task;
constructor(optionsArg:{taskFunction:any,preTask?:Task,afterTask?:Task, buffered?:boolean, bufferMax?:number}){
constructor(optionsArg:{
taskFunction:any,
preTask?:Task,
afterTask?:Task,
buffered?:boolean,
bufferMax?:number,
name?:string
}){
if (!optionsArg){optionsArg = {taskFunction:function(){}}}
var options = optionsArg;
this.task = optionsArg.taskFunction;
@ -26,6 +32,7 @@ export class Task {
this.idle = true;
this.buffered = options.buffered;
this.bufferMax = options.bufferMax;
this.name = options.name;
}
trigger(){

View File

@ -6,8 +6,11 @@ import helpers = require("./taskbuffer.classes.helpers");
export class Taskchain extends Task {
taskArray:Task[];
private _oraObject;
constructor(taskArrayArg:Task[]|Task){
super({
constructor(optionsArg:{
taskArray:Task[]
name?:string
}){
let options = plugins.lodash.assign(optionsArg,{
taskFunction: () => { // this is the function that gets executed when TaskChain is triggered
if(this.taskArray.length = 0) return; //make sure there is actually a Task available to execute
let startDeferred = plugins.Q.defer(); // this is the starting Deferred object
@ -21,6 +24,8 @@ export class Taskchain extends Task {
startDeferred.resolve();
}
});
super(options);
this.taskArray = optionsArg.taskArray;
this._oraObject = plugins.beautylog.ora("Taskchain idle","blue");
}
addTask(taskArg:Task){
@ -32,10 +37,17 @@ export class Taskchain extends Task {
shiftTask(){
};
trigger(){
this._oraObject.start(this.name + "running");
}
};
let myTask = new Taskchain(
new Task({
taskFunction:function(){}
})
{
taskArray: [
new Task({
taskFunction:function(){}
})
]
}
);

View File

@ -1,3 +1,4 @@
/// <reference path="./typings/main.d.ts" />
export import beautylog = require("beautylog");
export let Q = require("q");
export let lodash= require("lodash");