diff --git a/Repeat.podspec b/Repeat.podspec index 0c86c98..7af9729 100644 --- a/Repeat.podspec +++ b/Repeat.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Repeat" - s.version = "0.5.5" + s.version = "0.5.6" s.summary = "Modern NSTimer alternative in Swift" s.description = <<-DESC Repeat is a modern alternative to NSTimer; no strong references, multiple observers, reusable instances with start/stop/pause support in swifty syntax. diff --git a/Sources/Repeat/Repeater.swift b/Sources/Repeat/Repeater.swift index 762d29f..a9116d9 100644 --- a/Sources/Repeat/Repeater.swift +++ b/Sources/Repeat/Repeater.swift @@ -279,8 +279,8 @@ open class Repeater: Equatable { /// - observer: handler to call when timer fires. /// - Returns: timer instance @discardableResult - public class func once(after interval: Interval, queue: DispatchQueue? = nil, _ observer: @escaping Observer) -> Repeater { - let timer = Repeater(interval: interval, mode: .once, queue: queue, observer: observer) + public class func once(after interval: Interval, tolerance: DispatchTimeInterval = .nanoseconds(0), queue: DispatchQueue? = nil, _ observer: @escaping Observer) -> Repeater { + let timer = Repeater(interval: interval, mode: .once, tolerance: tolerance, queue: queue, observer: observer) timer.start() return timer } @@ -294,9 +294,9 @@ open class Repeater: Equatable { /// - handler: handler to call on fire /// - Returns: timer @discardableResult - public class func every(_ interval: Interval, count: Int? = nil, queue: DispatchQueue? = nil, _ handler: @escaping Observer) -> Repeater { + public class func every(_ interval: Interval, count: Int? = nil, tolerance: DispatchTimeInterval = .nanoseconds(0), queue: DispatchQueue? = nil, _ handler: @escaping Observer) -> Repeater { let mode: Mode = (count != nil ? .finite(count!) : .infinite) - let timer = Repeater(interval: interval, mode: mode, queue: queue, observer: handler) + let timer = Repeater(interval: interval, mode: mode, tolerance: tolerance, queue: queue, observer: handler) timer.start() return timer } @@ -396,7 +396,7 @@ open class Repeater: Equatable { if case .finite = self.mode { self.remainingIterations! -= 1 } - + // dispatch to observers self.observers.values.forEach { $0(self) }