I was trying to wrap Alamofire with async, but the answers that I found couldn’t help me, but after finding the solution, I thought that I should help some one with this same problem.
I was trying to wrap Alamofire with async, but the answers that I found couldn’t help me, but after finding the solution, I thought that I should help some one with this same problem.
2
Answers
Following a very decoupled MVVM project, my DataLayer was outside from the ViewModel Layer, so I couldn't let the AF.request handler the Diffable direct. So my solution was wraping the @escaping with withCheckedContinuation
In DataLayer.swift:
ModelModule.swift:
Finally the ViewModel.swift:
There’s no need to wrap Alamofire for async / await, it already offers a native version of that API.
You can also
await .result
andtry await .value
on the above to access the parts you need.