CombineSchedulers Documentation

Function timer(interval:​tolerance:​options:​)

public func timer(
      interval: SchedulerTimeType.Stride,
      tolerance: SchedulerTimeType.Stride = .zero,
      options: SchedulerOptions? = nil
    ) -> AsyncStream<SchedulerTimeType>  

Returns a stream that repeatedly yields the current time of the scheduler on a given interval.

If the task is cancelled, the sequence will terminate.

for await instant in scheduler.timer(interval: .seconds(1)) {
  print("now:", instant)
}

Parameters

interval Scheduler​Time​Type.​Stride

The time interval on which to sleep between yielding the current instant in time. For example, a value of 0.5 yields an instant approximately every half-second.

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.

Returns

A stream that repeatedly yields the current time.