Instance Method
register(priority:_:)
Spawns a Task whose lifetime is bound to the active scope.
@discardableResult func register(priority: TaskPriority? = nil, _ work: @escaping @Sendable () async -> Void) -> Task<Void, Never>
Parameters
- priority
An optional TaskPriority for the spawned task.
- work
The async work to run.
Return Value
The created Task. The result is discardable; the lifecycle retains the task and cancels it on deactivation.
Discussion
The task is added to the lifecycle’s bag of in-flight tasks and is cancelled by deactivate(invoking:). The default task(priority:_:) implementation forwards to this method; prefer that surface from feature code.