ursus
10/24/2020, 7:25 PMstartWith and flow onStart again
CoroutineScope(SupervisorJob() + Dispatchers.IO).launch {
flowOf(1)
.onStart { emit(0) }
.collect {
stateFlow.value = it
}
}
-- is equivalent to:
Observable.just(1)
.startWith(0) <---
.subscribeOn(Schedulers.io()) <---
.subscribe {
behaviorRelay.accept(it)
}
-- In rx I use:
Observable.just(1)
.subscribeOn(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 AMgildor
10/25/2020, 3:27 AMgildor
10/25/2020, 3:30 AMursus
10/25/2020, 1:42 PMgildor
10/25/2020, 2:25 PMgildor
10/25/2020, 2:25 PMursus
10/25/2020, 2:29 PM