Comments (12)
I'm also happy to do the work here. I mostly just want to agree on the idea & API before jumping in :)
from connectivity.
Sounds good to me! Will take a crack at this soon
from connectivity.
Actually I don't see tests anywhere⦠would you like some tests added?
from connectivity.
Thanks - I've merged that in now. Apologies, yes you are correct, I've been meaning to add some tests for a long time now but had been a little rushed off my feet. Now that you've reminded me to come back to this, I'll start adding some too.
from connectivity.
I've just created a release 3.2.0 containing your PR ππ»
from connectivity.
One way to do this without over-complicating the API would be to allow setting a block that gets called (with the URL that was requested and the response) to perform custom validation of all URLs. This block could return a result like this:
enum CustomValidationResult {
/// response for the url was validated successfully
case valid
/// response for the url was determined to be invalid
case invalid
/// perform the default / non-custom validation
case performDefaultValidation
}
from connectivity.
Hi Ben,
Sorry for the delay in getting back to you - thanks for the suggestion :) I've been having a think about this as well and one of the things I'm a little concerned about is the main file / class length is beginning to approach a length that will trigger linter warnings so it might be an idea to create a protocol e.g. ConnectivityResponseValidation
and then enable users to create a custom response validator which conforms to the protocol - this would avoid increasing the file / class length. A property e.g. responseValidator
could be set on the Connectivity
object enabling users to set their own implementation as the validator to be used. How does this sound?
from connectivity.
Sounds good to me! Similar behavior though? Custom validator can opt to handle the response or pass it back to the default validation to handle?
from connectivity.
Great ππ» I'd be happy with that solution.
from connectivity.
One thing I thought of was - currently ConnectivityResponseValidator
switches behavior based on the response validation mode passed in to the initializer (it will use string matching or regex). It might be a nice idea to split these out into separate validators conforming to the ConnectivityResponseValidation
protocol i.e. one for string matching, one for regex etc. That way in a custom validator you would be able to invoke the response validator of your choice depending on the URL you receive. If the only option is to fallback to a single default validator then the behavior of the default validator wouldn't be able to change per URL because the settings remain the same (the validation mode would remain unchanged for the default validator). Having different validators conforming to the protocol would also mean that the user could make use of any of these simply by assigning the relevant validator to the responseValidator
property.
from connectivity.
The initial PR is here: benasher44#1. I'll open a fresh one against this repo with tests once we discuss and also resolve what to do about #27.
from connectivity.
Awesome thanks!
from connectivity.
Related Issues (20)
- Carthage build fails because of "no shared framework schemes" HOT 6
- URLSession must be instantiated once for entire lifespan of Connectivity instance HOT 1
- Disable logging HOT 2
- Importing using SPM: Reachability missing HOT 12
- README/Documentation Appears Out of Date HOT 2
- Adding checks for Ethernet connection HOT 1
- App open and Airplane Mode on from Control Center HOT 5
- How do I monitor the switch from WiFi A to WiFi B? HOT 2
- Xcode / M1: could not find module 'Connectivity' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator HOT 2
- Wrong connectivity status returned when app is backgrounded HOT 1
- Building Connectivity with Carthage fails HOT 2
- Allow URLRequest & URL HOT 1
- Crashed: com.apple.root.background-qos
- Update podspec on cocoapods HOT 3
- custom `expectedResponse` not working when using Combine publisher mode HOT 6
- Failed connectivity URL HOT 2
- How we can check either the connected connection is poor? HOT 2
- Callback when isConnectedViaWiFiWithoutInternet changes
- Changes in 6.1.0 are breaking but no major version release HOT 1
- Crash in Xcode 15 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connectivity.