https://kotlinlang.org logo
#reaktive
Title
# reaktive
s

saket

08/13/2021, 4:36 AM
Am I reading this correctly that reaktive does not freeze items emitted by a
Source
?
subscribeOn
 freezes both its upstream source and downstream observer, all the Disposables (upstream’s and downstream’s) are frozen as well, all the values (including errors) are not frozen by the operator
I’m consuming an
Observable
from k/native, and I wanted to confirm that doing this is expected:
Copy code
upstream.map {  it.freeze() }
a

Arkadii Ivanov

08/13/2021, 9:02 AM
Actually operators do not freeze anything, but schedulers do. The
subscribeOn
operator affects only the subscription phase, so it does not freeze emitted values. But
observeOn
affects emission, and it does freeze values.
Why do you need to freeze values manually?
s

saket

08/13/2021, 2:39 PM
Ah I feel stupid to miss the next paragraph where this was mentioned:
observeOn
 freezes only its downstream observer and all the values (including errors) passed through it, plus all the Disposables, upstream source is not frozen by the operator
Why do you need to freeze values manually?
I’m letting consuming platforms, android and macOS, control the thread where the emissions are observed, which explains why my emissions weren’t getting auto-frozen.
👍 1
7 Views