Skip to content
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

Merged
merged 7 commits into from
Mar 2, 2023

Conversation

TheNoim
Copy link
Contributor

@TheNoim TheNoim commented Feb 25, 2023

No description provided.

@@ -93,4 +94,9 @@ typealias Configuration = ConnectivityConfiguration // For internal use.
self.urlSessionConfiguration = urlSessionConfiguration
return self
}

Copy link

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)

Connectivity/Classes/Connectivity.swift Outdated Show resolved Hide resolved
@@ -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?

Copy link

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)

Copy link

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
}

Copy link

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
}

Copy link

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)

Copy link
Owner

@rwbutler rwbutler left a 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.

Connectivity/Classes/Connectivity.swift Outdated Show resolved Hide resolved
Connectivity/Classes/Connectivity.swift Show resolved Hide resolved
self.authorizationHeader = value
return self
}

Copy link

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 {
}
}
}

Copy link

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)
}

Copy link

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)
}

Copy link

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
}

Copy link

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
}
}

Copy link

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
}

Copy link

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
}

Copy link

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
}

Copy link

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
}
}

Copy link

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
}

Copy link

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)

@TheNoim TheNoim requested a review from rwbutler March 1, 2023 22:19
Copy link
Owner

@rwbutler rwbutler left a 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 👍

@rwbutler rwbutler merged commit 4472b90 into rwbutler:master Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants