-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow to configure framework via fluent api #73
Conversation
@@ -93,4 +94,9 @@ typealias Configuration = ConnectivityConfiguration // For internal use. | |||
self.urlSessionConfiguration = urlSessionConfiguration | |||
return self | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -33,6 +33,10 @@ public class Connectivity: NSObject { | |||
|
|||
/// Optionally configure a bearer token to be sent as part of an Authorization header. | |||
public var bearerToken: String? | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
self.bearerToken = token | ||
return self | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
self.framework = framework | ||
return self | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheNoim thanks for the PR! 🙏 Appreciate the contribution - thanks for spotting that certain values weren't configurable via the configuration object. I can see the value in being able to set an auth header so this change makes sense to me - I've added a couple of small comments which should be easy to address.
self.authorizationHeader = value | ||
return self | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -702,7 +719,7 @@ private extension Connectivity { | |||
} | |||
} | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -678,7 +695,7 @@ private extension Connectivity { | |||
self.isConnected = isConnected | |||
status = status(from: networkStatus, isConnected: isConnected) | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -669,7 +686,7 @@ private extension Connectivity { | |||
self.isConnected = isConnected | |||
status = status(from: path, isConnected: isConnected) | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
/// Determines whether a change in connectivity has taken place. | ||
private func statusHasChanged(previousStatus: ConnectivityStatus?, currentStatus: ConnectivityStatus) -> Bool { | ||
guard let previousStatus = previousStatus else { | ||
return true | ||
} | ||
return previousStatus != currentStatus | ||
} | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -652,15 +669,15 @@ private extension Connectivity { | |||
return isConnected ? .connectedViaWiFi : .connectedViaWiFiWithoutInternet | |||
} | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -581,7 +598,7 @@ private extension Connectivity { | |||
} | |||
previousStatus = currentStatus // Update for the next connectivity check | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
/// Whether or not the we should use the Network framework on iOS 12+. | ||
func isNetworkFramework() -> Bool { | ||
return framework == .network | ||
} | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
/// Determines whether enough connectivity checks have succeeded to be considered connected. | ||
private func isThresholdMet(_ successfulChecks: UInt, outOf totalChecks: UInt) -> Bool { | ||
return Percentage(successfulChecks, outOf: totalChecks) >= successThreshold | ||
} | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -559,17 +576,17 @@ private extension Connectivity { | |||
return nil | |||
} | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
@@ -546,7 +563,7 @@ private extension Connectivity { | |||
} | |||
return false | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Have merged 👍
No description provided.