Skip to content

Commit

Permalink
Add if argument to retry(times:)
Browse files Browse the repository at this point in the history
  • Loading branch information
srdanrasic committed May 20, 2020
1 parent fe00e0f commit 657faa9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ReactiveKit.podspec
Original file line number Diff line number Diff line change
@@ -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" => "[email protected]" }
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'
Expand Down
2 changes: 2 additions & 0 deletions ReactiveKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Sources/SignalProtocol+ErrorHandling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Element, Error> {
public func retry(_ times: Int, if shouldRetry: @escaping (Error) -> Bool = { _ in true }) -> Signal<Element, Error> {
guard times > 0 else { return toSignal() }
return Signal { observer in
let lock = NSRecursiveLock(name: "com.reactive_kit.signal.retry")
Expand All @@ -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 {
Expand Down

0 comments on commit 657faa9

Please sign in to comment.