CombineSchedulers Documentation

Function sleep(until:​tolerance:​options:​)

public func sleep(
      until deadline: SchedulerTimeType,
      tolerance: SchedulerTimeType.Stride = .zero,
      options: SchedulerOptions? = nil
    ) 

Suspend task execution until a given deadline within a tolerance.

If the task is cancelled before the time ends, this function throws CancellationError.

This function doesn't block the scheduler.

try await in scheduler.sleep(until: scheduler.now + .seconds(1))

Parameters

deadline Scheduler​Time​Type

An instant of time to suspend until.

tolerance Scheduler​Time​Type.​Stride

The allowed timing variance when emitting events. Defaults to zero.

options Scheduler​Options?

Scheduler options passed to the timer. Defaults to nil.