DateScheduler
public protocol DateScheduler : Scheduler
A particular kind of scheduler that supports enqueuing actions at future dates.
-
The current date, as determined by this scheduler.
This can be implemented to deterministically return a known date (e.g., for testing purposes).
Declaration
Swift
var currentDate: Date { get }
-
Schedules an action for execution at or after the given date.
Declaration
Swift
@discardableResult func schedule(after date: Date, action: @escaping () -> Void) -> Disposable?
Parameters
date
The start date.
action
A closure of the action to be performed.
Return Value
Optional
Disposable
that can be used to cancel the work before it begins. -
Schedules a recurring action at the given interval, beginning at the given date.
Note
If you plan to specify an
interval
value greater than 200,000 seconds, useschedule(after:interval:leeway:action)
instead and specify your ownleeway
value to avoid potential overflow.Declaration
Swift
@discardableResult func schedule(after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable?
Parameters
date
The start date.
interval
A repetition interval.
leeway
Some delta for repetition.
action
A closure of the action to be performed.
Return Value
Optional
Disposable
that can be used to cancel the work before it begins.