ComposeNodeLifecycleCallback
- Common/All
- Android/JVM
-
Cmn
interface ComposeNodeLifecycleCallback
Observes lifecycle of the node emitted with ReusableComposeNode
or ComposeNode
inside ReusableContentHost
and ReusableContent
.
The ReusableContentHost
introduces the concept of reusing (or recycling) nodes, as well as deactivating parts of composition, while keeping the nodes around to reuse common structures in the next iteration. In this state, RememberObserver
is not sufficient to track lifetime of data associated with reused node, as deactivated or reused parts of composition is disposed.
These callbacks track intermediate states of the node in reusable groups for managing data contained inside reusable nodes or associated with them (e.g. subcomposition).
Important: the runtime only supports node implementation of this interface.
Summary
Public functions
onDeactivate
fun onDeactivate(): Unit
Invoked when the group containing the node was deactivated. This happens when the content of ReusableContentHost
is deactivated.
The node will not be reused in this recompose cycle, but might be reused or released in the future. Consumers might use this callback to release expensive resources or stop continuous process that was dependent on the node being used in composition.
If the node is reused, onReuse
will be called again to prepare the node for reuse. Similarly, onRelease
will indicate that deactivated node will never be reused again.