Skip to content

Instantly share code, notes, and snippets.

@n8ebel
Last active January 25, 2018 03:39
Show Gist options
  • Save n8ebel/7a45c8e9ebd807aa7dbab67785fb051d to your computer and use it in GitHub Desktop.
Save n8ebel/7a45c8e9ebd807aa7dbab67785fb051d to your computer and use it in GitHub Desktop.
Activity subscription to viewmodel ToastState
viewModel.toastPub.subscribe { toastData ->
when(toastData) {
is ShortToast -> Toast.makeText(this, toastData.msgId, Toast.LENGTH_SHORT).show()
is LongToast -> Toast.makeText(this, toastData.msgId, Toast.LENGTH_LONG).show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment