CombineSchedulers Documentation

Structure UIScheduler

public struct UIScheduler: Scheduler, Sendable  

A scheduler that executes its work on the main queue as soon as possible.

This scheduler is inspired by the equivalent scheduler in the ReactiveSwift project.

If UIScheduler.shared.schedule is invoked from the main thread then the unit of work will be performed immediately. This is in contrast to DispatchQueue.main.schedule, which will incur a thread hop before executing since it uses DispatchQueue.main.async under the hood.

This scheduler can be useful for situations where you need work executed as quickly as possible on the main thread, and for which a thread hop would be problematic, such as when performing animations.

%7 UIScheduler UIScheduler Sendable Sendable UIScheduler->Sendable Scheduler Scheduler UIScheduler->Scheduler

Conforms To

Scheduler
Sendable

Nested Type Aliases

Scheduler​Options

public typealias SchedulerOptions = Never

Scheduler​Time​Type

public typealias SchedulerTimeType = DispatchQueue.SchedulerTimeType

Properties

test

public static var test: TestSchedulerOf<Self>  

A test scheduler compatible with type erased UI schedulers.

shared

public static let shared  

The shared instance of the UI scheduler.

You cannot create instances of the UI scheduler yourself. Use only the shared instance.

now

public var now: SchedulerTimeType  

minimum​Tolerance

public var minimumTolerance: SchedulerTimeType.Stride  

Methods

schedule(options:​_:​)

public func schedule(options: SchedulerOptions? = nil, _ action: @escaping () -> Void)  

schedule(after:​tolerance:​options:​_:​)

public func schedule(
      after date: SchedulerTimeType,
      tolerance: SchedulerTimeType.Stride,
      options: SchedulerOptions? = nil,
      _ action: @escaping () -> Void
    )  

schedule(after:​interval:​tolerance:​options:​_:​)

public func schedule(
      after date: SchedulerTimeType,
      interval: SchedulerTimeType.Stride,
      tolerance: SchedulerTimeType.Stride,
      options: SchedulerOptions? = nil,
      _ action: @escaping () -> Void
    ) -> Cancellable