RunLoop.main vs DispatchQueue.main: The differences explained

PHOTO EMBED

Sat Jan 18 2025 12:28:51 GMT+0000 (Coordinated Universal Time)

Saved by @kaushalPal0812 #swift

URLSession.shared
    .dataTaskPublisher(for: URL(string: "https://picsum.photos/300/600")!)
    .map(\.data)
    .compactMap(UIImage.init)

    /// Schedule to receive the sink closure on the
    /// main dispatch queue.
    .receive(on: DispatchQueue.main, options: nil)
    
    .sink { _ in
        print("Image loading completed")
    } receiveValue: { image in
        self.image = image
    }.store(in: &cancellables)
content_copyCOPY

https://www.avanderlee.com/combine/runloop-main-vs-dispatchqueue-main/