jean
val state: StateFlow<MyViewState> = myFlow .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), MyViewState())
lifecycleOwner.addRepeatingJob(Lifecycle.State.STARTED) { viewModel.state.collect { // do something with the data } }
SharingStarted.WhileSubscribed()
Manuel Vivo
myFlow
WhileSubscribed()
WhileSubscribed
Eagerly
Lazily
Remy Benza
A modern programming language that makes developers happier.