ursus
10/24/2020, 7:25 PMstartWith
and flow onStart
again
CoroutineScope(SupervisorJob() + <http://Dispatchers.IO|Dispatchers.IO>).launch {
flowOf(1)
.onStart { emit(0) }
.collect {
stateFlow.value = it
}
}
-- is equivalent to:
Observable.just(1)
.startWith(0) <---
.subscribeOn(<http://Schedulers.io|Schedulers.io>()) <---
.subscribe {
behaviorRelay.accept(it)
}
-- In rx I use:
Observable.just(1)
.subscribeOn(<http://Schedulers.io|Schedulers.io>()) <---
.startWith(0) <--- swapped
.subscribe {
behaviorRelay.accept(it)
}
is this doable somehow in flow? (to not have the onStart emit coming from io thread)gildor
10/25/2020, 3:26 AMursus
10/25/2020, 1:42 PMgildor
10/25/2020, 2:25 PMursus
10/25/2020, 2:29 PM