# Class Task

## Task 任务实体

parentTaskId用来处理多层级任务的问题 例如 如果父级任务是前置任务 且 包含了多个子级任务 这个时候 子级任务是永远不会执行 因为有且只能有一个前置任务 前置任务里面的子级任务排在前置任务后面 所以不会执行 这个时候需要用这个parentTaskId进行关系绑定 *

#### Hierarchy

- Task

- Defined in src/task.ts:39

#####
Index

### Constructors

constructor

### Properties

asyncFunction
error
failTimes
id
isPreCondition
level
onFail
onMoving
onProcessing
onReady
onSuccess
parentTaskId
result
status

### Methods

addFailTimes
execute
updateStatus

## Constructors

### constructor

- new Task(config: TaskConfig): Task

- #### Parameters

  - ##### config: TaskConfig

  #### Returns Task

  - Defined in src/task.ts:70

## Properties

### `Readonly` asyncFunction

asyncFunction: ((Task: any) => Promise<any>) = ...

#### Type declaration

- - (Task: any): Promise<any>

  - 任务执行的异步函数 *

    #### Parameters

    - ##### Task: any

    #### Returns Promise<any>

- Defined in src/task.ts:45

### error

error: any = undefined

任务执行失败报错信息 *

- Defined in src/task.ts:53

### failTimes

failTimes: number = 0

任务失败次数 *

- Defined in src/task.ts:49

### `Readonly` id

id: string = ...

任务ID *

- Defined in src/task.ts:41

### isPreCondition

isPreCondition: boolean = false

- Defined in src/task.ts:57

### `Readonly` level

level: number = 0

任务优先等级 *

- Defined in src/task.ts:47

### `Private` `Readonly` onFail

onFail: ((task: Task, message?: any) => Promise<any>) = ...

#### Type declaration

- - (task: Task, message?: any): Promise<any>

  - 任务执行失败回调 *

    #### Parameters

    - ##### task: Task

    - ##### `Optional` message: any

    #### Returns Promise<any>

- Defined in src/task.ts:66

### `Private` `Readonly` onMoving

onMoving: ((task: Task, message?: any) => Promise<any>) = ...

#### Type declaration

- - (task: Task, message?: any): Promise<any>

  - 任务被移动的回调 移动期间不允许对任务进行其他操作 例如从成功的队列移动到失败的队列 *

    #### Parameters

    - ##### task: Task

    - ##### `Optional` message: any

    #### Returns Promise<any>

- Defined in src/task.ts:62

### `Private` `Readonly` onProcessing

onProcessing: ((task: Task, message?: any) => Promise<any>) = ...

#### Type declaration

- - (task: Task, message?: any): Promise<any>

  - 任务执行中的回调 *

    #### Parameters

    - ##### task: Task

    - ##### `Optional` message: any

    #### Returns Promise<any>

- Defined in src/task.ts:68

### `Private` `Readonly` onReady

onReady: ((task: Task, message?: any) => Promise<any>) = ...

#### Type declaration

- - (task: Task, message?: any): Promise<any>

  - 任务准备状态回调 会被触发多次 *

    #### Parameters

    - ##### task: Task

    - ##### `Optional` message: any

    #### Returns Promise<any>

- Defined in src/task.ts:60

### `Private` `Readonly` onSuccess

onSuccess: ((task: Task, message?: any) => Promise<any>) = ...

#### Type declaration

- - (task: Task, message?: any): Promise<any>

  - 任务执行成功回调 *

    #### Parameters

    - ##### task: Task

    - ##### `Optional` message: any

    #### Returns Promise<any>

- Defined in src/task.ts:64

### `Readonly` parentTaskId

parentTaskId: string = ""

父级任务ID *

- Defined in src/task.ts:43

### result

result: any[] = []

任务执行成功结果 *

- Defined in src/task.ts:51

### status

status: TASK_STATUS = TASK_STATUS.READY

任务状态 *

- Defined in src/task.ts:55

## Methods

### `Private` addFailTimes

- addFailTimes(): Promise<void>

- 失败次数增加 *

  #### Returns Promise<void>

  - Defined in src/task.ts:130

### execute

- execute(): Promise<any>

- 执行任务 *

  #### Returns Promise<any>

  - Defined in src/task.ts:135

### updateStatus

- updateStatus(status: TASK_STATUS, message?: any): Promise<void>

- 任务状态更新 *

  #### Parameters

  - ##### status: TASK_STATUS

  - ##### `Optional` message: any

  #### Returns Promise<void>

  - Defined in src/task.ts:100

Generated using TypeDoc