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
dateThe start date.
actionA closure of the action to be performed.
Return Value
Optional
Disposablethat 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
intervalvalue greater than 200,000 seconds, useschedule(after:interval:leeway:action)instead and specify your ownleewayvalue to avoid potential overflow.Declaration
Swift
@discardableResult func schedule(after date: Date, interval: DispatchTimeInterval, leeway: DispatchTimeInterval, action: @escaping () -> Void) -> Disposable ?Parameters
dateThe start date.
intervalA repetition interval.
leewaySome delta for repetition.
actionA closure of the action to be performed.
Return Value
Optional
Disposablethat can be used to cancel the work before it begins.