Home > AI > IOS > Combine >

Publishers.Zip3

Example 1:

let url1 = URL(string: "https://www.jobyme88.com/wp-content/uploads/2020/11/50d0-kj-classroom-0.jpg")!
let url2 = URL(string: "https://www.jobyme88.com/wp-content/uploads/2020/11/50d0-kj-classroom-1.jpg")!
let url3 = URL(string: "https://www.jobyme88.com/wp-content/uploads/2020/11/50d0-kj-classroom-2.jpg")!



let combined = Publishers.Zip3(
    URLSession.shared.dataTaskPublisher(for: url1),
    URLSession.shared.dataTaskPublisher(for: url2),
    URLSession.shared.dataTaskPublisher(for: url3)
)

let cancellable = combined.sink(receiveCompletion: { print("\($0)") },
              receiveValue: { (value1, value2, value3) in
                print(value1, "\n\n\n\n")
                print(value2, "\n\n\n\n")
                print(value3, "\n\n\n\n")
              })

Leave a Reply