Threads

Information

Important difference between how to handle threads while subscribing or working with the UI in RxSwift

Check thread type

Use default Thread.isMainThread in the subscribe block in order to identify whether the thread is Main thread or background thread.

Observable<Int>.create { observer in
    observer.onNext(1)
 return Disposables.create()
}
.subscribe(onNext: { el in
    print(Thread.isMainThread)
})

Code snippet from the article linked below about ObserveOn vs subscribeOn

Articles

ObserveOn vs subscribeOn

thread-safety-with-subjects-in-rxswift

SO issue | rxswift-not-subscribing-on-main-thread

RxSwift Multithreading examples

RxSwift Deepcuts

Mind Map

concurrency_rxSwift

Observe