Package 

Class SingleLiveEvent


  • 
    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.

    • Method Summary

      Modifier and Type Method Description
      Unit observe(LifecycleOwner owner, Observer<in T> observer)
      Unit setValue(T t)
      final Unit call() 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