Skip to content

Instantly share code, notes, and snippets.

@zivkesten
Created June 8, 2020 06:40
Show Gist options
  • Save zivkesten/a2f60810fe64e561eed58356b65d16c5 to your computer and use it in GitHub Desktop.
Save zivkesten/a2f60810fe64e561eed58356b65d16c5 to your computer and use it in GitHub Desktop.
MVI - viewModel event function
fun event(event: Event) {
when(event) {
is Event.DataReceived -> handleScreenLoadState(event.data)
is Event.LinkClicked -> viewAction.postValue(ViewEffect.NavigateToLink(data?.url))
is Event.AddToFavouritesClicked -> viewAction.postValue(ViewEffect.ShowSnackBar(
R.string.button_result_text
))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment