Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jbcorreia's full-sized avatar
🚀

Joao Correia jbcorreia

🚀
View GitHub Profile
@jbcorreia
jbcorreia / 01_SnackBarMessageBus.kt
Last active November 22, 2017 02:56
Simple Message/Event Bus using the Architecture Component LiveData
// 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