@mentor-apm/react-sortable-tree
Version:
Drag-and-drop sortable component for nested data and hierarchies
18 lines (14 loc) • 427 B
text/typescript
import type { Task } from './types.js'
import { RawTask } from './RawTask.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
}
}