Skip to content

Instantly share code, notes, and snippets.

@JoseAlcerreca
Last active September 28, 2020 02:36
Show Gist options
  • Save JoseAlcerreca/97ab91e056351fdb61fe59e8e8bcc269 to your computer and use it in GitHub Desktop.
Save JoseAlcerreca/97ab91e056351fdb61fe59e8e8bcc269 to your computer and use it in GitHub Desktop.
class ListViewModel : ViewModel {
private val _navigateToDetails = MutableLiveData<Event<String>>()
val navigateToDetails : LiveData<Event<String>>
get() = _navigateToDetails
fun userClicksOnButton(itemId: String) {
_navigateToDetails.value = Event(itemId) // Trigger the event by setting a new Event as a new value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment