Notify Observer when item is added to List of LiveData

I use a Kotlin Extension Function to make it easier:

fun <T> MutableLiveData<T>.notifyObserver() {
    this.value = this.value
}

Then use it in any MutableLiveData like this:

fun addIssuePost(issuePost: IssuePost) {
    mIssuePostLiveData.value?.add(issuePost)
    mIssuePostLiveData.notifyObserver()
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)