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.
Relationships
Conforms To
Scheduler
Sendable
Nested Type Aliases
SchedulerOptions
public typealias SchedulerOptions = Never
SchedulerTimeType
public typealias SchedulerTimeType = DispatchQueue.SchedulerTimeType
Properties
test
public static var test: TestSchedulerOf<Self>
A test scheduler compatible with type erased UI schedulers.
now
public var now: SchedulerTimeType
minimumTolerance
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