From 657faa987330879852b4117937b632b108a11400 Mon Sep 17 00:00:00 2001 From: Srdan Rasic Date: Wed, 20 May 2020 13:50:06 +0200 Subject: [PATCH] Add if argument to retry(times:) --- ReactiveKit.podspec | 4 ++-- ReactiveKit.xcodeproj/project.pbxproj | 2 ++ Sources/SignalProtocol+ErrorHandling.swift | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ReactiveKit.podspec b/ReactiveKit.podspec index dc33b76..9af3157 100644 --- a/ReactiveKit.podspec +++ b/ReactiveKit.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = "ReactiveKit" - s.version = "3.17.1" + s.version = "3.17.3" s.summary = "A Swift Reactive Programming Framework" s.description = "ReactiveKit is a Swift framework for reactive and functional reactive programming." s.homepage = "https://github.com/DeclarativeHub/ReactiveKit" s.license = 'MIT' s.author = { "Srdan Rasic" => "srdan.rasic@gmail.com" } - s.source = { :git => "https://github.com/DeclarativeHub/ReactiveKit.git", :tag => "v3.17.1" } + s.source = { :git => "https://github.com/DeclarativeHub/ReactiveKit.git", :tag => "v3.17.3" } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.11' diff --git a/ReactiveKit.xcodeproj/project.pbxproj b/ReactiveKit.xcodeproj/project.pbxproj index b29567f..0a6fbc9 100644 --- a/ReactiveKit.xcodeproj/project.pbxproj +++ b/ReactiveKit.xcodeproj/project.pbxproj @@ -1169,6 +1169,7 @@ INFOPLIST_FILE = "Supporting Files/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 3.17.3; PRODUCT_BUNDLE_IDENTIFIER = DeclarativeHub.ReactiveKit; PRODUCT_NAME = ReactiveKit; SKIP_INSTALL = YES; @@ -1191,6 +1192,7 @@ INFOPLIST_FILE = "Supporting Files/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 3.17.3; PRODUCT_BUNDLE_IDENTIFIER = DeclarativeHub.ReactiveKit; PRODUCT_NAME = ReactiveKit; SKIP_INSTALL = YES; diff --git a/Sources/SignalProtocol+ErrorHandling.swift b/Sources/SignalProtocol+ErrorHandling.swift index 577dccd..6510dc2 100644 --- a/Sources/SignalProtocol+ErrorHandling.swift +++ b/Sources/SignalProtocol+ErrorHandling.swift @@ -96,7 +96,7 @@ extension SignalProtocol { } /// Retry the signal in case of failure at most `times` number of times. - public func retry(_ times: Int) -> Signal { + public func retry(_ times: Int, if shouldRetry: @escaping (Error) -> Bool = { _ in true }) -> Signal { guard times > 0 else { return toSignal() } return Signal { observer in let lock = NSRecursiveLock(name: "com.reactive_kit.signal.retry") @@ -111,7 +111,7 @@ extension SignalProtocol { observer.receive(element) case .failed(let error): lock.lock(); defer { lock.unlock() } - if _remainingAttempts > 0 { + if _remainingAttempts > 0 && shouldRetry(error) { _remainingAttempts -= 1 _attempt?() } else {