setObserver

abstract fun setObserver(lifecycleOwner: LifecycleOwner, liveEffectsObserver: Observer<T>)

A utility method for calling .setObserver] that substitutes null for the optional observer. See linked method doc for full info.


abstract fun setObserver(lifecycleOwner: LifecycleOwner, liveEffectsObserver: Observer<T>, pausedEffectsObserver: Observer<Iterable<T>>?)

The LiveQueue supports only a single observer, so calling this method will override any previous observers set.

Effects while the lifecycle is active are sent only to the liveEffectsObserver.

Once the lifecycle owner goes into Paused state, no effects will be forwarded, however, if the state changes to Resumed, all effects that occurred while Paused will be passed to the optional pausedEffectsObserver. If this optional observer is not provided, these effects will be ignored.

Effects that occur while there is no lifecycle owner set will not be queued.

Parameters

lifecycleOwner

This required parameter is used to queue effects while its state is Paused and to resume sending effects once it resumes.

liveEffectsObserver

This required observer will be forwarded all effects while the lifecycle owner is in a Resumed state.

pausedEffectsObserver

The nullable observer will be invoked when the lifecycle owner resumes, and will receive a queue of effects, ordered as they occurred while paused.