jean
03/25/2021, 9:13 AMval state: StateFlow<MyViewState> = myFlow
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), MyViewState())
does one stills need to use something like this from a view
lifecycleOwner.addRepeatingJob(Lifecycle.State.STARTED) {
viewModel.state.collect {
// do something with the data
}
}
i’m not completely sure what SharingStarted.WhileSubscribed()
implies regarding android and its life cycleManuel Vivo
03/25/2021, 9:25 AMmyFlow
is or how it’s implemented.
WhileSubscribed()
means that when there are no collectors available, the underlying flow will be cancelled.Manuel Vivo
03/25/2021, 9:26 AMWhileSubscribed
to Eagerly
or Lazily
jean
03/25/2021, 9:29 AMRemy Benza
03/26/2021, 8:35 AMRemy Benza
03/26/2021, 8:35 AM