MutableLiveData
-
android
class MutableLiveData<T> : LiveData
MediatorLiveData |
|
LiveData which publicly exposes setValue and postValue method.
| Parameters | |
|---|---|
<T> |
The type of data hold by this instance |
Summary
Public constructors |
|
|---|---|
|
Creates a MutableLiveData with no value assigned to it. |
android
|
MutableLiveData(value: T!)Creates a MutableLiveData initialized with the given |
android
|
Public functions |
||
|---|---|---|
Unit |
postValue(value: T!)Posts a task to a main thread to set the given value. |
android
|
Unit |
setValue(value: T!)Sets the value. |
android
|
Inherited functions |
||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableLiveData
MutableLiveData(value: T!)
Creates a MutableLiveData initialized with the given value.
| Parameters | |
|---|---|
value: T! |
initial value |
Public functions
postValue
fun postValue(value: T!): Unit
Posts a task to a main thread to set the given value. So if you have a following code executed in the main thread:
liveData.postValue("a"); liveData.setValue("b");
If you called this method multiple times before a main thread executed a posted task, only the last value would be dispatched.
| Parameters | |
|---|---|
value: T! |
The new value |