60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
/// <reference path="./typings/main.d.ts" />
|
|
import plugins = require("./taskbuffer.plugins");
|
|
import helpers = require("./taskbuffer.classes.helpers");
|
|
export class Task {
|
|
task:any;
|
|
idle:boolean;
|
|
running:boolean;
|
|
buffered:boolean;
|
|
private _counterBufferRelative;
|
|
private _counterTriggerAbsolute;
|
|
private _state:string;
|
|
preTask:Task;
|
|
afterTask:Task;
|
|
|
|
constructor(taskArg,optionsArg:{preTask?:Task,afterTask?:Task, buffered?:boolean} = {}){
|
|
var options = optionsArg;
|
|
this.task = taskArg;
|
|
this.preTask = options.preTask;
|
|
this.afterTask = options.afterTask;
|
|
this.idle = true;
|
|
this.running = false;
|
|
if (typeof options.buffered === "boolean"){
|
|
this.buffered = options.buffered;
|
|
} else {
|
|
this.buffered = false;
|
|
}
|
|
}
|
|
trigger(){
|
|
helpers.runTask(this.preTask)
|
|
.then(function(){
|
|
|
|
})
|
|
.then(function(){
|
|
|
|
})
|
|
};
|
|
triggerBuffered(){
|
|
var done = plugins.Q.defer();
|
|
}
|
|
|
|
get state():string {
|
|
return this._state;
|
|
}
|
|
set state(stateArg:string){
|
|
if (stateArg == "locked"){
|
|
this._state = "locked";
|
|
} else {
|
|
plugins.beautylog.error("state type" );
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
export class TaskChain extends Task {
|
|
constructor(taskArrayArg:Task[]){
|
|
super({
|
|
task: function(){}
|
|
});
|
|
}
|
|
} |