Is there a way to use have a `MutableStateFlow<...
# coroutines
r
Is there a way to use have a
MutableStateFlow<T : Any>
where the initial value is not set immediately? I am migrating from RxJava2
BehaviorSubject<T : Any>
. The value is not initialized until some process finishes. Observers of the value are transient. I would rather it not be a
T?
where I filter out the initial null value. Thanks!
t
SharedFlow
MutableSharedFlow
to be exact
r
Does SharedFlow replay values for late observers?
t
yes
StateFlow extends SharedFlow in fact
r
Interesting. StateFlow is similar to SharedFlow with replay of 1
t
yes, and conflated
😆 1
and with an initial value.
g
is similar to SharedFlow
It’s not just similar, it is essentially SharedFlow with replace 1 (though both MutableSharedFlow and MutableStateFlow have some own features, but both based on AbstractSharedFlow implementation) https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/common/src/flow/StateFlow.kt#L76-L80
t
yes that comment just describes exactly what I said, replay 1, conflated, and with an initial value
âž• 1