From 7bada7b863b197b0c273e6a09962bae26880a657 Mon Sep 17 00:00:00 2001 From: Christian Steffens Date: Tue, 17 Jul 2018 21:10:15 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Adds=20tolerance=20argument=20to=20?= =?UTF-8?q?=E2=80=98once=E2=80=99=20and=20=E2=80=98every=E2=80=99=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Repeat/Repeater.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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) } From 3efa2e2a567d4c52bc909fd07ca959464342cfce Mon Sep 17 00:00:00 2001 From: Daniele Margutti Date: Wed, 18 Jul 2018 09:48:28 +0200 Subject: [PATCH 2/2] Bump to 0.5.6 --- Repeat.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.