UseWorkerResult
Defined in: react/use-worker.ts:21
Snapshot of a useWorker run.
Extends
Section titled “Extends”WorkerState<T>
Type Parameters
Section titled “Type Parameters”T
Properties
Section titled “Properties”cancel
Section titled “cancel”cancel: () =>
void
Defined in: react/use-worker.ts:30
Abort the in-flight run, moving status to cancelled.
Returns
Section titled “Returns”void
data:
T|undefined
Defined in: react/use-worker.ts:14
Result of the last successful run; preserved across later runs until one succeeds.
Inherited from
Section titled “Inherited from”error:
unknown
Defined in: react/use-worker.ts:16
Error thrown by the last failed run (not set for cancellations).
Inherited from
Section titled “Inherited from”isRunning
Section titled “isRunning”isRunning:
boolean
Defined in: react/use-worker.ts:18
True while a run is in flight.
Inherited from
Section titled “Inherited from”reset: () =>
void
Defined in: react/use-worker.ts:32
Abort and reset back to idle (clears data/error).
Returns
Section titled “Returns”void
run: (
task) =>Promise<T|undefined>
Defined in: react/use-worker.ts:28
Start task. Any in-flight run is aborted first (run-exclusive), and only
the latest run may settle the state (latest-wins) — a superseded run’s
result/error is discarded. Resolves with the value, or undefined if the
run was superseded, cancelled, or failed.
Parameters
Section titled “Parameters”WorkerTask<T>
Returns
Section titled “Returns”Promise<T | undefined>
status
Section titled “status”status:
WorkerStatus
Defined in: react/use-worker.ts:12
Current lifecycle status.