The RxAndroid library provides a scheduler that uses the main thread. The following example code shows how to use this scheduler:
Flowable.fromIterable(listOf(1, 2, 3))
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { println(it) }
The preceding snippet shows how to use the observeOn method to handle emitted values on the main thread.