taskbuffer/dist/taskbuffer.classes.task.d.ts

63 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-02-15 21:52:29 +00:00
import * as helpers from './taskbuffer.classes.helpers';
2016-08-01 11:17:15 +00:00
export interface ITaskFunction {
(x?: any): PromiseLike<any>;
2016-08-01 11:17:15 +00:00
}
2016-05-04 02:28:50 +00:00
export declare class Task {
2016-05-14 02:28:22 +00:00
name: string;
taskFunction: ITaskFunction;
2016-05-04 02:28:50 +00:00
buffered: boolean;
2017-07-10 10:42:06 +00:00
bufferMax: number;
execDelay: number;
2016-05-04 02:28:50 +00:00
preTask: Task;
afterTask: Task;
2016-08-01 14:10:00 +00:00
running: boolean;
bufferRunner: helpers.BufferRunner;
cycleCounter: helpers.CycleCounter;
idle: boolean;
private _state;
constructor(optionsArg: {
2017-07-10 10:42:06 +00:00
/**
* the task function to run, must return promise
*/
2016-08-01 11:17:15 +00:00
taskFunction: ITaskFunction;
2017-07-10 10:42:06 +00:00
/**
* any other task to run before
*/
2016-05-04 02:28:50 +00:00
preTask?: Task;
2017-07-10 10:42:06 +00:00
/**
* any other task to run after
*/
2016-05-04 02:28:50 +00:00
afterTask?: Task;
2017-07-10 10:42:06 +00:00
/**
* wether this task should run buffered
*/
2016-05-04 02:28:50 +00:00
buffered?: boolean;
2017-07-10 10:42:06 +00:00
/**
* the maximum buffer
*/
2016-05-05 17:21:50 +00:00
bufferMax?: number;
2017-07-10 10:42:06 +00:00
/**
* the execution delay, before the task is executed
* only makes sense when running in buffered mode
*/
execDelay?: number;
/**
* the name of the task
*/
name?: string;
2016-05-04 02:28:50 +00:00
});
2016-08-01 11:17:15 +00:00
/**
* trigger the task. Will trigger buffered if this.buffered is true
*/
2016-08-03 12:51:43 +00:00
trigger(x?: any): Promise<any>;
2016-08-01 11:17:15 +00:00
/**
* trigger task unbuffered.
*/
2016-08-03 12:51:43 +00:00
triggerUnBuffered(x?: any): Promise<any>;
2016-08-01 11:17:15 +00:00
/**
* trigger task buffered.
*/
2016-08-03 12:51:43 +00:00
triggerBuffered(x?: any): Promise<any>;
2016-05-04 02:28:50 +00:00
state: string;
}