Documentation / dataflow-async / com.femastudios.dataflow.async.util / com.femastudios.dataflow.listen.LifecycleOwner / listen
Go to reference

listen

fun <T> LifecycleOwner.listen(attribute: Attribute<T>, callback: (AttributeData<T>) -> Unit): ListenerHolder<AttributeData<T>>
fun <T> LifecycleOwner.listen(attribute: Attribute<T>, callback: Consumer<AttributeData<T>>): ListenerHolder<AttributeData<T>>
fun <T> LifecycleOwner.listen(attribute: Attribute<T>, callImmediately: Boolean, callback: (AttributeData<T>) -> Unit): ListenerHolder<AttributeData<T>>
fun <T> LifecycleOwner.listen(attribute: Attribute<T>, callImmediately: Boolean, callback: Consumer<AttributeData<T>>): ListenerHolder<AttributeData<T>>

Starts listening to the given Attribute.

When Attribute changes, callback is called.

Return
the ListenerHolder that manages this listening. You can call stop to stop the listening, and start to listen again.


fun <T> LifecycleOwner.listen(attribute: Attribute<T>, key: Any, callback: (AttributeData<T>) -> Unit): ListenerHolder<AttributeData<T>>
fun <T> LifecycleOwner.listen(attribute: Attribute<T>, key: Any, callback: Consumer<AttributeData<T>>): ListenerHolder<AttributeData<T>>
fun <T> LifecycleOwner.listen(attribute: Attribute<T>, key: Any, callImmediately: Boolean, callback: (AttributeData<T>) -> Unit): ListenerHolder<AttributeData<T>>
fun <T> LifecycleOwner.listen(attribute: Attribute<T>, key: Any, callImmediately: Boolean, callback: Consumer<AttributeData<T>>): ListenerHolder<AttributeData<T>>

Starts listening to the given Attribute.

When Attribute changes, callback is called.

If another listener is attached with the same key, the previous listener will detach.

Return
the ListenerHolder that manages this listening. You can call stop to stop the listening, and start to listen again.