Go to reference
BaseLifecycleOwner
open class BaseLifecycleOwner : MapLifecycleOwner
A basic implementation of LifecycleOwner. It is usually sufficient to use the lifecycle function instead.
Constructors
<init> |
A basic implementation of LifecycleOwner. It is usually sufficient to use the lifecycle function instead. BaseLifecycleOwner(canSafelyUseStrongListeners: Boolean = false) |
Properties
attachedItems |
The map that contains the attached ListenerHolder. The map will be automatically used by attachedItems and detachFromLifecycle. val attachedItems: MutableMap<Any, ListenerHolder<*>> |
canSafelyUseStrongListeners |
Whether or not listeners will be registered strongly to this LifecycleOwner.
Defaults to open val canSafelyUseStrongListeners: Boolean |
isDestroyed |
Whether this BaseLifecycleOwner has been destroyed var isDestroyed: Boolean |
isStarted |
Whether this BaseLifecycleOwner is started and active var isStarted: Boolean |
startListenersAutomatically |
Whether or not listeners will start automatically when calling listen. open val startListenersAutomatically: Boolean |
Functions
attachToLifecycle |
Attaches the given ListenerHolder to the lifecycle of this object Detaches and returns the previous ListenerHolder attached under key fun attachToLifecycle(key: Any, listenerHolder: ListenerHolder<*>): ListenerHolder<*>? |
callListenersIfNeeded |
Calls all the attached listeners if there are changes. Useful to call listeners when this LifecycleOwner is stopped fun callListenersIfNeeded(): Unit |
destroy |
Destroys this LifecycleOwner. Destroys all attached listeners. As a consequence, no listeners will be attached to this LifecycleOwner. fun destroy(): Unit |
detachFromLifecycle |
Detaches the ListenerHolder attached under key fun detachFromLifecycle(key: Any): ListenerHolder<*>?
Detaches the given ListenerHolder fun detachFromLifecycle(key: Any, listenerHolder: ListenerHolder<*>): ListenerHolder<*>? |
isAttached |
Returns true if the given listenerHolder is attached with the given key fun isAttached(key: Any, listenerHolder: ListenerHolder<*>): Boolean |
listen |
Starts listening to the given Field. open fun <T> listen(field: Field<T>, key: Any, callImmediately: Boolean, callback: (T) -> Unit): ListenerHolder<T> |
start |
Starts this LifecycleOwner. Starts all attached listeners. If a particular Field changed while the associates ListenerHolder was stopped, the callback will be called. fun start(): Unit |
stop |
Stops this LifecycleOwner. Stops all attached listeners. fun stop(): Unit |