-
public final class SingleLiveEvent<T extends Object> extends MutableLiveData<T>
A lifecycle-aware observable that sends only new updates after subscription, used for events like navigation and Snackbar messages.
This avoids a common problem with events: on configuration change (like rotation) an update can be emitted if the observer is active. This LiveData only calls the observable if there's an explicit call to setValue() or call().
Note that only one observer is going to be notified of changes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classSingleLiveEvent.Companion
-
Field Summary
Fields Modifier and Type Field Description private final ObjectmDataLockprivate final IntegermActiveCountprivate final ObjectmPendingData
-
Constructor Summary
Constructors Constructor Description SingleLiveEvent()
-
Method Summary
Modifier and Type Method Description Unitobserve(LifecycleOwner owner, Observer<in T> observer)UnitsetValue(T t)final Unitcall()Used for cases where T is Void, to make calls cleaner. -
Methods inherited from class androidx.lifecycle.MutableLiveData
changeActiveCounter, dispatchingValue, getValue, getVersion, hasActiveObservers, hasObservers, isInitialized, observeForever, onActive, onInactive, removeObserver, removeObservers -
Methods inherited from class com.pluto.utilities.SingleLiveEvent
postValue -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
observe
@MainThread() Unit observe(LifecycleOwner owner, Observer<in T> observer)
-
setValue
@MainThread() Unit setValue(T t)
-
call
@MainThread() final Unit call()
Used for cases where T is Void, to make calls cleaner.
-
-
-
-