feat: add api doc

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-03-24 17:59:18 +08:00
parent f5a7a269e4
commit 73b9c2f163
4 changed files with 69 additions and 9 deletions

View File

@@ -1,7 +1,15 @@
export namespace task {
export const TaskManager = Symbol('TaskManager')
export interface TaskManager {
/**
* 创建任务
* @param func 任务内容
*/
create(func: Function): task.Task;
/**
* 在主线程执行代码
* @param func 执行内容
*/
callSyncMethod(func: Function): any;
}
/**
@@ -19,16 +27,28 @@ export namespace task {
this.func = func;
}
/**
* 设置任务异步执行
* @param isAsync 是否异步
*/
async(isAsync: boolean = true): task.Task {
this.isAsync = isAsync;
return this;
}
/**
* 设置任务延时执行
* @param tick 延时 Tick
*/
later(tick: number): task.Task {
this.laterTime = tick;
return this;
}
/**
* 设置任务循环执行
* @param tick 循环时间 Tick
*/
timer(tick: number): task.Task {
this.interval = tick;
return this;
@@ -43,6 +63,9 @@ export namespace task {
}
}
/**
* 提交任务
*/
abstract submit(): Cancelable;
}
/**