Documentation / dataflow / com.femastudios.dataflow.listen / MapLifecycleOwner
Go to reference

MapLifecycleOwner

interface MapLifecycleOwner : LifecycleOwner

An implementation of LifecycleOwner that uses a Map to hold the ListenerHolder

A possible implementation is:

class A : MapLifecycleOwner {
	override val attachedItems = HashMap<Any, ListenerHolder<*>>()
}

Properties

attachedItems

The map that contains the attached ListenerHolder. The map will be automatically used by attachedItems and detachFromLifecycle.

abstract val attachedItems: MutableMap<Any, ListenerHolder<*>>

Functions

attachToLifecycle

Attaches the given ListenerHolder to the lifecycle of this object Detaches and returns the previous ListenerHolder attached under key

open fun attachToLifecycle(key: Any, listenerHolder: ListenerHolder<*>): ListenerHolder<*>?

detachFromLifecycle

Detaches the given ListenerHolder

open fun detachFromLifecycle(key: Any, listenerHolder: ListenerHolder<*>): ListenerHolder<*>?

Detaches the ListenerHolder attached under key

open fun detachFromLifecycle(key: Any): ListenerHolder<*>?

isAttached

Returns true if the given listenerHolder is attached with the given key

open fun isAttached(key: Any, listenerHolder: ListenerHolder<*>): Boolean

Inheritors

BaseLifecycleOwner

A basic implementation of LifecycleOwner. It is usually sufficient to use the lifecycle function instead.

open class BaseLifecycleOwner : MapLifecycleOwner