Andrew Steinmetz
09/22/2021, 4:49 PMsubscribeOn
and observeOn
. When I was looking at the Todo sample I saw the repository had the following which if I understand correctly will make sure the values being observed are consumed on the background thread? Is there a reason to not also chain a subscribeOn(ioScheduler)
to enforce all values computed are on a background thread? Or is that just SqlDelight only doing queries on a background thread that prevents the need for that?
private fun <T : Any> query(query: (TodoDatabaseQueries) -> Query<T>): Single<Query<T>> =
queries
.observeOn(ioScheduler)
.map(query)
I noticed that in one of the stores that observeOn(mainScheduler)
is only called to make sure updates to UI are done on the UI, but there is no subscribeOn(ioScheduler)
so was curious how the computations were being done on a background thread?
database
.updates
.observeOn(mainScheduler)
.map(Result::ItemsLoaded)
.subscribeScoped(onNext = ::dispatch)
Thanks!Arkadii Ivanov
09/22/2021, 5:34 PMAndrew Steinmetz
09/23/2021, 4:16 PM