DispatchTimer
public class DispatchTimer
DispatchTimer is a general-purpose wrapper over the DispatchSourceTimer mechanism in GCD.
-
The state of a
See moreDispatchTimer.Declaration
Swift
public enum State -
Declaration
Swift
public typealias Payload = DispatchSource.DispatchSourceHandler -
Declaration
Swift
public static let defaultAccuracy: DispatchTimeInterval -
Timer current state.
Declaration
Swift
private(set) public var state: State { get } -
Initializes a new timer.
Declaration
Swift
public init(countdown: DispatchTimeInterval, repeating repetition: DispatchTimeInterval = .never, accuracy: DispatchTimeInterval = defaultAccuracy, executingOn executionQueue: DispatchQueue = .main, payload: @escaping Payload)Parameters
countdownThe initial time interval for the timer to wait before firing off the payload for the first time.
repeatingThe subsequent time interval for the timer to wait before firing off the payload an additional time. Repeats until manually stopped.
accuracyThe amount of leeway, expressed as a time interval, that the timer has in it’s timing of the payload execution. Default is 500 milliseconds.
executingOnthe queue on which the timer executes. Default is main queue.
payloadThe payload that executes when the timer expires.
-
Arm the timer. Countdown will begin after this function returns.
Declaration
Swift
public func arm() -
Re-arm the timer. Countdown will restart after this function returns.
Declaration
Swift
public func reset() -
Disarm the timer. Countdown will stop after this function returns.
Declaration
Swift
public func disarm()
Install in Dash
DispatchTimer Class Reference