Skip to content

Instantly share code, notes, and snippets.

@alexshr
Last active August 7, 2019 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexshr/493e1aaa2a52dde3c897ae60a13a3b67 to your computer and use it in GitHub Desktop.
Save alexshr/493e1aaa2a52dde3c897ae60a13a3b67 to your computer and use it in GitHub Desktop.
LiveEvent sample (for snackbar)
/**
* Snackbar LiveEvent
* (see https://github.com/hadilq/LiveEvent)
* This is private because we don't want to expose setting this value to the Fragment.
*/
private val snackBarEvent = LiveEvent<String>()
val showSnackBarEvent: LiveData<String> = snackBarEvent
//https://github.com/hadilq/LiveEvent
implementation "com.github.hadilq.liveevent:liveevent:1.0.1"
sample:
https://github.com/alexshr/andfun-kotlin-sleep-tracker/blob/master/app/src/main/java/com/example/android/trackmysleepquality/sleeptracker/SleepTrackerViewModel.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment