LiveDataScope
interface LiveDataScope<T extends Object>
Interface that allows controlling a LiveData from a coroutine block.
| See also | |
|---|---|
liveData |
|
Summary
Public methods |
|
|---|---|
abstract void |
|
abstract @NonNull DisposableHandle |
emitSource(@NonNull LiveData<@NonNull T> source)Add the given |
Public fields
latestValue
@Nullable
public abstract @Nullable T latestValue
References the current value of the LiveData.
If the block never emited a value, latestValue will be null. You can use this value to check what was then latest value emited by your block before it got cancelled.
Note that if the block called emitSource, then latestValue will be last value dispatched by the sourceLiveData.
Public methods
emit
@NonNull
public abstract void emit(@NonNull T value)
Set's the LiveData's value to the given value. If you've called emitSource previously, calling emit will remove that source.
Note that this function suspends until the value is set on the LiveData.
| See also | |
|---|---|
emitSource |
|
emitSource
@NonNull
public abstract DisposableHandle emitSource(@NonNull LiveData<@NonNull T> source)
Add the given LiveData as a source, similar to MediatorLiveData.addSource. Calling this method will remove any source that was yielded before via emitSource.
| Parameters | |
|---|---|
@NonNull LiveData<@NonNull T> source |
The |
| See also | |
|---|---|
emit |
|
addSource |
|
removeSource |
|