CombineSchedulers Documentation

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

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

Suspends the current task for at least the given duration.

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(for: .seconds(1))

Parameters

duration Scheduler​Time​Type.​Stride

The time interval on which to sleep between yielding.

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.