lifecycle/livedata-core/src/main/java/androidx/lifecycle/LiveData.java
@MainThread
    public void observeForever(@NonNull Observer<? super T> observer) {
        assertMainThread("observeForever");
        AlwaysActiveObserver wrapper = new AlwaysActiveObserver(observer);
        ObserverWrapper existing = mObservers.putIfAbsent(observer, wrapper);
        if (existing != null && existing instanceof LiveData.LifecycleBoundObserver) {
            throw new IllegalArgumentException("Cannot add the same observer"
                    + " with different lifecycles");
        }
        if (existing != null) {
            return;
        }
        wrapper.activeStateChanged(true);
    }
/**
     * Adds the given observer to the observers list. This call is similar to
     * {@link LiveData#observe(LifecycleOwner, Observer)} with a LifecycleOwner, which
     * is always active. This means that the given observer will receive all events and will never
     * be automatically removed. You should manually call {@link #removeObserver(Observer)} to stop
     * observing this LiveData.
     * While LiveData has one of such observers, it will be considered
     * as active.
     * <p>
     * If the observer was already added with an owner to this LiveData, LiveData throws an
     * {@link IllegalArgumentException}.
     *
     * @param observer The observer that will receive the events
     */
Adds the given observer to the observers list. This call is similar to
LiveData#observe(LifecycleOwner, Observer) with a LifecycleOwner, which
is always active. This means that the given observer will receive all events and will never
be automatically removed. You should manually call  #removeObserver(Observer) to stop
observing this LiveData.
While LiveData has one of such observers, it will be considered
as active.

If the observer was already added with an owner to this LiveData, LiveData throws an
IllegalArgumentException.

@param observer The observer that will receive the events
Adds the given observer to the observers list . This call is similar to LiveData#observe ( LifecycleOwner Observer ) with a LifecycleOwner which is always active . This means that the given observer will receive all events and will never be automatically removed . You should manually call #removeObserver ( Observer ) to stop observing this LiveData . While LiveData has one of such observers it will be considered as active . If the observer was already added with an owner to this LiveData LiveData throws an IllegalArgumentException . @param observer The observer that will receive the events
@MainThread
    public void observeForever(@NonNull Observer<? super T> observer) {
        assertMainThread("observeForever");
        AlwaysActiveObserver wrapper = new AlwaysActiveObserver(observer);
        ObserverWrapper existing = mObservers.putIfAbsent(observer, wrapper);
        if (existing != null && existing instanceof LiveData.LifecycleBoundObserver) {
            throw new IllegalArgumentException("Cannot add the same observer"
                    + " with different lifecycles");
        }
        if (existing != null) {
            return;
        }
        wrapper.activeStateChanged(true);
    }
@ MainThread public void observeForever ( @ NonNull Observer < ? super T > observer ) { assertMainThread ( "observeForever" ) ; AlwaysActiveObserver wrapper = new AlwaysActiveObserver ( observer ) ; ObserverWrapper existing = mObservers . putIfAbsent ( observer , wrapper ) ; if ( existing != null && existing instanceof LiveData . LifecycleBoundObserver ) { throw new IllegalArgumentException ( "Cannot add the same observer" + " with different lifecycles" ) ; } if ( existing != null ) { return ; } wrapper . activeStateChanged ( true ) ; }
Adds the given observer to the observers list.
Adds the given observer to the observers list .