Created
September 23, 2019 07:16
-
-
Save bdsaglam/5454d9e330d0c4b4fac18d591f93523a to your computer and use it in GitHub Desktop.
LiveData with explicit notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/52075248/6641096 | |
fun <T> MutableLiveData<T>.notifyObserver() { | |
this.value = this.value | |
} | |
// Usage | |
fun addSomething(item: Item) { | |
listLiveData.value?.add(item) | |
listLiveData.notifyObserver() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment