BottleRocketStudios / iOS-Hyperspace

An extremely lightweight wrapper around URLSession to make working with APIs a breeze.
Apache License 2.0
47 stars 17 forks source link

Add support for async/await functionality #141

Closed GrandLarseny closed 2 years ago

GrandLarseny commented 2 years ago

With the new back support for async/await in versions of iOS 13 and later, it appears that many more project will want to use async/await with hyperspace.

Let's go ahead and incorporate async/await

GrandLarseny commented 2 years ago

Interestingly, the data(...) async throws function in URLSession is only available in iOS 15 and later. Since that's the case I'm just going for wrapping the existing BackendService.execute() call in an await withCheckedThrowingContinuation block, similar to the futures wrapper.

It's inelegant, but efficient and a working solution. I'd like to revisit once URLSession's async version is supported in iOS 13 (which probably will happen. Probably.)

wmcginty commented 2 years ago

Closing with merge of #142