I have an array of Promise of different type. In this particular case Promise<URL>
and Promise<UIImage>
which I want to provide to when(fulfilled:)
As an example:
let fileName = "somefilename"
let videos: [URL] = selectedItems.compactMap { guard $0.isVideo else {return nil}; return URL(string: $0.url) }
let images: [URL] = selectedItems.compactMap { guard !$0.isVideo else {return nil}; return URL(string: $0.url) }
let videoRequests = videos.map { RemoteDownloadManager.shared.downloadVideo(from: $0, withName: fileName) }
let imgRequests = images.map {RemoteDownloadManager.shared.downloadImage(from: $0)}
I have two arrays of promises, but of different types: [Promise<UIImage>]
and [Promise<URL]
.
Is there a way to call when(fulfilled)
with a combined, casted, array?
when(fulfilled: [imgRequests, videoRequests])
.done { items in
// [...]
}
This won't compile (Obviously) with error: Cannot invoke 'when' with an argument list of type '(fulfilled: [Any])'
Ideas?