Blame view

天文台pc/tianwentai-ui/node_modules/@react-dnd/asap/src/RawTask.ts 494 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  // We wrap tasks with recyclable task objects.  A task object implements
  
  import type { Task, TaskFn } from 'types'
  
  // `call`, just like a function.
  export class RawTask implements Task {
  	public task: TaskFn | null = null
  
  	public constructor(
  		private onError: (err: any) => void,
  		private release: (t: RawTask) => void,
  	) {}
  
  	public call() {
  		try {
  			this.task && this.task()
  		} catch (error) {
  			this.onError(error)
  		} finally {
  			this.task = null
  			this.release(this)
  		}
  	}
  }