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
Name | Type | Description |
---|---|---|
interval | SchedulerTimeType.Stride |
The time interval on which to sleep between yielding the current instant in time. For example, a value of |
tolerance | SchedulerTimeType.Stride |
The allowed timing variance when emitting events. Defaults to |
options | SchedulerOptions? |
Scheduler options passed to the timer. Defaults to |
Returns
A stream that repeatedly yields the current time.