ITaskBaseOptions
Defined in: src/types/ITaskOptions.ts:8
Base options for a Task, shared by task creation and Task.reset.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”TData = any
Properties
Section titled “Properties”enabled?
Section titled “enabled?”
optionalenabled?:boolean
Defined in: src/types/ITaskOptions.ts:13
Whether the task is currently enabled. This gives manual control over
execution: while false, the task bypasses its callback. Default: true.
optionallead?:boolean
Defined in: src/types/ITaskOptions.ts:20
Whether to run the task once immediately when the timer starts (the leading
edge), in addition to its normal tick schedule — instead of waiting a full
interval for the first tick. Ignored while a future startDate has not been
reached. Applies on start() only. Default: false.
optionaldata?:TData
Defined in: src/types/ITaskOptions.ts:26
Arbitrary user data attached to the task, available as task.data in the
callback and event listeners. Type it via the TData parameter, e.g.
timer.get<MyType>(id). Default: undefined.
tickDelay?
Section titled “tickDelay?”
optionaltickDelay?:number
Defined in: src/types/ITaskOptions.ts:31
Number of ticks to wait before running the task for the first time.
Default: 0.
tickInterval?
Section titled “tickInterval?”
optionaltickInterval?:number
Defined in: src/types/ITaskOptions.ts:37
Tick interval the task runs on. The unit is ticks, not milliseconds: with a
timer interval of 1000 ms, a tickInterval of 5 runs the task every 5
seconds. Default: 1.
totalRuns?
Section titled “totalRuns?”
optionaltotalRuns?:number|null
Defined in: src/types/ITaskOptions.ts:42
Total number of times the task should run. 0 or null means unlimited,
until stopDate is reached or the timer stops. Default: null.
startDate?
Section titled “startDate?”
optionalstartDate?:number|Date
Defined in: src/types/ITaskOptions.ts:47
Date/time (or timestamp) to start executing the task. If omitted, the task runs on its tick interval right after the timer starts.
stopDate?
Section titled “stopDate?”
optionalstopDate?:number|Date
Defined in: src/types/ITaskOptions.ts:53
Date/time (or timestamp) to stop executing the task. If totalRuns is
reached first, the task is considered completed regardless. If omitted, the
task runs until totalRuns is fulfilled or the timer stops.
defer?
Section titled “defer?”
optionaldefer?:boolean
Defined in: src/types/ITaskOptions.ts:60
Whether to defer the callback to the next event-loop turn (via
setImmediate) before executing, so it yields instead of running inline on
the tick. Useful when the task synchronously blocks the event loop without
doing I/O or using JS timers. Default: false.
removeOnCompleted?
Section titled “removeOnCompleted?”
optionalremoveOnCompleted?:boolean
Defined in: src/types/ITaskOptions.ts:66
Whether to remove the task (freeing memory) once it has completed its runs.
For this to take effect, the task must have totalRuns and/or stopDate
configured. Default: false.
callback
Section titled “callback”callback:
TaskCallback<TData>
Defined in: src/types/ITaskOptions.ts:70
Callback executed on each run of the task. See TaskCallback.