Files
igny8/frontend/node_modules/@react-dnd/asap/src/TaskFactory.ts
2025-11-09 10:27:02 +00:00

18 lines
427 B
TypeScript

import { RawTask } from './RawTask.js'
import type { Task } from './types.js'
export class TaskFactory {
private freeTasks: RawTask[] = []
public constructor(private onError: (err: any) => void) {}
public create(task: () => void): Task {
const tasks = this.freeTasks
const t = tasks.length
? (tasks.pop() as RawTask)
: new RawTask(this.onError, (t) => (tasks[tasks.length] = t))
t.task = task
return t
}
}