Combine, retrieve array of images from array of URLs and assign them to corresponding object

I am quite new using Combine and frankly I don’t know whether this question is silly or not, anyway I have a publisher which I then return to the caller with an array of objects retrieved from a RESTful operation in the following way:

let publisher = URLSession.shared.dataTaskPublisher(for: URL)
                receiveSubscription: { _ in
                }, receiveCompletion: { _ in
                }, receiveCancel: {
            .tryMap { data, response -> Data in
                guard let httpResponse = response as? HTTPURLResponse,
                      httpResponse.statusCode == 200 else {
                          throw NetworkError.httpError
                print(String(data: data, encoding: .utf8) ?? "")
                return data
            .decode(type: [ShowElement].self, decoder: JSONDecoder())
            .map { $0 }
            .catch { err -> Just<[ShowElement]> in
                return Just([])
        return publisher

One of the properties of my objects is an URL to download an image, I have prepared a Data? var property for the downloaded image but I can’t figure out how to integrate the download in this pipeline, I mean it would be cycling every object in {0} retrieve the URL and then asynchronously download each image ad assign the data to the appropriate object property. Is this even feasible in a single pipeline?


DevKit — The ultimate developer toolkit

Bharti Airtel Prepaid Plans With OTT Benefits Under Rs 1000