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

Unit

Invoked when the group containing the node was deactivated.

Cmn
Unit

Invoked when the node exits the composition entirely and won't be reused again.

Cmn
Unit

Invoked when the node was reused in the composition.

Cmn

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.

onRelease

fun onRelease(): Unit

Invoked when the node exits the composition entirely and won't be reused again. All intermediate data related to the node can be safely disposed.

onReuse

fun onReuse(): Unit

Invoked when the node was reused in the composition. Consumers might use this callback to reset data associated with the previous content, as it is no longer valid.