When I look at the documentation of Combine framework, I see an example on the
/// let jsonPublisher = MyJSONLoaderPublisher() // Some publisher. /// let labelUpdater = MyLabelUpdateSubscriber() // Some subscriber that updates the UI. /// /// jsonPublisher /// .subscribe(on: backgroundQueue) /// .receiveOn(on: RunLoop.main) /// .subscribe(labelUpdater) public func receive<S>(on scheduler: S, options: S.SchedulerOptions? = nil) -> Publishers.ReceiveOn<Self, S> where S : Scheduler
I'm curious what's the difference between
DispatchQueue.main as the scheduler when dispatching to the main queue.
I found a same question on StackOverflow but with no answer.
BTW, I believe there is a typo in the official documentation?
/// jsonPublisher /// .subscribe(on: backgroundQueue) /// .receiveOn(on: RunLoop.main) <------ should be receive(on: RunLoop.main)