Closed vox-humana closed 2 years ago
Yes, the plan is to make it available on earlier platforms as soon as Xcode 13.2 drops. I'm planning to work on it this weekend – add CI, add more tests, document it.
Wow, that sounds like you already have a clear plan for the library 🙂 Happy to provide any help. I am thinking to use the library with my hobby playground projects, so I personally don't need old platforms support (Linux support probably would be nice though).
Also, I've played a bit with the custom async URLSession.data
implementation and faced two issues:
testCancellingTheRequest
Probably just don't have enough experience with Swift structured concurrency yet (who has 😅)URLSessionTaskDelegate
was added to URLSessionTask
only with the latest SDKs. Even though currently the library doesn't use the delegate it might be a problem for Pulse integration (it was mentioned in the blog post). Workaround could be to use URLSessionDelegate
and keep references to tasks but that might overcomplicate design of the library a lot.Hope these thoughts are useful.
Basically I can't pass testCancellingTheRequest
Is the test not passing for you or you are not getting the cancellation event in your code? What platform and Xcode are you running it on? I'm not 100% confident in the cancellation logic of the new URLSession
async APIs, but I was satisfied when I saw URLSession
throwing URLError.cancelled
, but maybe I'm missing something.
Seems that URLSessionTaskDelegate was added to URLSessionTask only with the latest SDKs.
Yeah, you are right. And it's not just the delegate, it's all new async APIs. Not sure how I missed that. Looks like I'll need to implement them myself.
Is the test not passing for you or you are not getting the cancellation event in your code?
I couldn't figure out how to receive cancellation and then I've discovered withTaskCancellationHandler
🤦
it's all new async APIs. Not sure how I missed that. Looks like I'll need to implement them myself.
Yeah, that was exactly my experiment. Without URLSessionDelegate
it seems relatively easy. See pull request #3
I'm also planning to add code generation soon. I don't like what the existing OpenAPI tools produce. And I need a name for this library, I'm thinking Nano.
Personally, have never used code generation for REST, probably, because has never met a proper OpenAPI/Swagger spec for any backend production service 😅 However, I got the idea. Also, if there is a plan for code generation maybe graphQL might be squeezed there as well 🤔
You're good in concise naming. Seems like Nano opens a door for the big 2.0 version named Micro though (dad jokes)
As there are no dependencies on iOS SDK, enabled other Apple platforms. In theory, with custom implementation of
URLSession.data(for:)
it could be ported to previous OS versions (requires Xcode 13.2) and Linux. Unfortunately, seems that custom URLProtocol doesn't properly works with POST requests on watchOS and Mocker doesn't have any non-iOS tests to re-verify. All other tests work on all platforms.