TaskCallback
TaskCallback<
TData> = (task,done?) =>void|Promise<unknown>
Defined in: src/types/TaskCallback.ts:23
Callback executed on each run of a task. The task itself is passed as the
first argument. For an async task, either return a Promise or call the
done function passed as the second argument when the work is finished.
Type Parameters
Section titled “Type Parameters”TData = any
Parameters
Section titled “Parameters”Task<TData>
The task being executed.
() => void
Marks an async task as finished. Omit for sync tasks or when
returning a Promise.
Returns
Section titled “Returns”void | Promise<unknown>
Examples
Section titled “Examples”// sync timer.add(task => console.log(task.currentRuns));// async via done() timer.add((task, done) => fs.readFile(path, () => done()));// async via Promise timer.add(task => readFileAsync(path).then(process));