Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Joao Correia jbcorreia

🚀
View GitHub Profile
@jbcorreia
jbcorreia / 01_SnackBarMessageBus.kt
Last active Nov 22, 2017
Simple Message/Event Bus using the Architecture Component LiveData
View 01_SnackBarMessageBus.kt
// Define our singleton Event Bus
object SnackBarMessageBus {
private val snackBarMessageBUS = MutableLiveData<String>()
fun sendMessage(message: String) {
if (snackBarMessageBUS.hasActiveObservers()) {
snackBarMessageBUS.postValue(message)
// We need to re-set the value because we want this to be displayed only once