I am trying to call a Swift 5.5 async throws method inside a method that should return an AnyPublisher but I am having trouble to achieve this. I tried using a Future (promise) which did not work and I only managed to find a Swift 5.5 API to convert closure based methods to async ones.
class Loader {
func loadSomeData() -> async throws [String] {
/// some code
}
}
class Service {
let loader: Loader
init(loader: Loader) {
self.loader = loader
}
func someDataPublisher() -> AnyPublisher<[String], Error> {
// How can I convert this?
try await loader.loadSomeData()
}
}