I'm a little bit confused about the order you can call the subscribeOn
and observeOn
methods on observables. I read a couple of posts and one guys says that it doesn't matter and just uses thing in his example and other people say it does matter. So here is my question:
For example:
self.remoteService.rxGetAllLanguages()
.observeOn(MainScheduler.instance)
.subscribeOn(ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Background))
.subscribe({ e in
switch e {
case .Next(let element):
case .Error(let e):
DDLogError("Error in \(e)")
case .Completed:
DDLogDebug("Completed")
}
}
).addDisposableTo(self.disposeBag)
Is that the same as:
self.remoteService.rxGetAllLanguages()
.subscribeOn(ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Background))
.observeOn(MainScheduler.instance)
.subscribe({ e in
switch e {
case .Next(let element):
case .Error(let e):
DDLogError("Error in \(e)")
case .Completed:
DDLogDebug("Completed")
}
}
).addDisposableTo(self.disposeBag)
If I correctly understand the mechanisms they are different. The first one does all the work on the main thread and the second does all the work on another thread and then dispatches back to the main thread. But I'm nut sure so can someone clear this for me please?