Skip to content

Instantly share code, notes, and snippets.

@saeedashrafy
Last active February 9, 2021 20:55
Show Gist options
  • Save saeedashrafy/8cf759bc8ee0b35b99f35a184eab0254 to your computer and use it in GitHub Desktop.
Save saeedashrafy/8cf759bc8ee0b35b99f35a184eab0254 to your computer and use it in GitHub Desktop.
class HomeViewModel(private val getFoodsUseCase: GetFoodUseCase) : ViewModel() {
// intialize viewState
init {
val initialVS = ViewState.initial()
viewState = _intentFlow.toPartialStateChanges()
.scan(initialVS) { state, changes -> changes.reduce(state) }
.stateIn(viewModelScope, SharingStarted.Eagerly, initialVS)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment