Skip to content

Commit

Permalink
feat: MutableLiveData utils
Browse files Browse the repository at this point in the history
  • Loading branch information
percula committed Sep 24, 2019
1 parent 1acd411 commit b6e5e87
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/src/main/java/dev/percula/ktx/MutableLiveData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.percula.ktx

import androidx.lifecycle.MutableLiveData

/**
* Creates a [MutableLiveData] with the initial value set
* @param value Initial value to set
* @return [MutableLiveData] with the initial value set
*/
fun <T> mutableLiveDataOf(value: T?): MutableLiveData<T> {
val liveData = MutableLiveData<T>()
liveData.value = value
return liveData
}

/**
* Creates a [MutableLiveData] with no initial value
*/
fun <T> mutableLiveDataOf(): MutableLiveData<T> {
return MutableLiveData()
}

0 comments on commit b6e5e87

Please sign in to comment.