SubcomposeLayoutState


State used by SubcomposeLayout.

slotReusePolicy the policy defining what slots should be retained to be reused later.

Summary

Nested types

Instance of this interface is returned by precompose function.

Public constructors

State used by SubcomposeLayout.

Cmn
SubcomposeLayoutState(maxSlotsToRetainForReuse: Int)

This function is deprecated. This constructor is deprecated

Cmn
Cmn

Public functions

SubcomposeLayoutState.PrecomposedSlotHandle
precompose(slotId: Any?, content: @Composable () -> Unit)

Composes the content for the given slotId.

Cmn

Public constructors

SubcomposeLayoutState

SubcomposeLayoutState()

State used by SubcomposeLayout.

SubcomposeLayoutState

SubcomposeLayoutState(maxSlotsToRetainForReuse: Int)

State used by SubcomposeLayout.

Parameters
maxSlotsToRetainForReuse: Int

when non-zero the layout will keep active up to this count slots which we were used but not used anymore instead of disposing them. Later when you try to compose a new slot instead of creating a completely new slot the layout would reuse the previous slot which allows to do less work especially if the slot contents are similar.

SubcomposeLayoutState

SubcomposeLayoutState(slotReusePolicy: SubcomposeSlotReusePolicy)

Public functions

precompose

fun precompose(slotId: Any?, content: @Composable () -> Unit): SubcomposeLayoutState.PrecomposedSlotHandle

Composes the content for the given slotId. This makes the next scope.subcompose(slotId) call during the measure pass faster as the content is already composed.

If the slotId was precomposed already but after the future calculations ended up to not be needed anymore (meaning this slotId is not going to be used during the measure pass anytime soon) you can use PrecomposedSlotHandle.dispose on a returned object to dispose the content.

Parameters
slotId: Any?

unique id which represents the slot we are composing into.

content: @Composable () -> Unit

the composable content which defines the slot.

Returns
SubcomposeLayoutState.PrecomposedSlotHandle

PrecomposedSlotHandle instance which allows you to dispose the content.