dead.fish
11/29/2022, 4:58 PMval flow: StateFlow<T>
to consumers, while individual implementations can fill in the initial state via some protected abstract suspend fun initialState(): T
. But I can’t get lazy initialization working, i.e. my backing MutableSharedFlow<T>(replay = 1)
needs suspending to be converted into a StateFlow
or needs the initial value being given again (repeated), which defeats the purpose, i.e. val flow: StateFlow<T> get() = backingFlow.onStart { emit(initialState()) }.stateIn(someScope)
does not work, because stateIn(someScope)
is suspending. What am I doing wrong?Sam
11/29/2022, 5:00 PMvalue
property to return before the initial state has been computed?Casey Brooks
11/29/2022, 5:20 PMStateFlow<T?>
and set the initial value to null until the lazy value has been computed.dead.fish
11/29/2022, 10:15 PM.value
property needs to be accessible all the time. Guess I have to rethink my architecture a little then. Will probably start with a real static / empty value and only afterwards fill in realistic things.dead.fish
11/29/2022, 10:15 PM