SubcomposeSlotReusePolicy
-
Cmn
interface SubcomposeSlotReusePolicy
This policy allows SubcomposeLayout to retain some of slots which we were used but not used anymore instead of disposing them. Next time when you try to compose a new slot instead of creating a completely new slot the layout would reuse the kept slot. This allows to do less work especially if the slot contents are similar.
Summary
Nested types |
|---|
|
Set containing slot ids currently available to reuse. |
Public functions |
||
|---|---|---|
Boolean |
areCompatible(slotId: Any?, reusableSlotId: Any?)Returns true if the content previously composed with |
Cmn
|
Unit |
This function will be called with |
Cmn
|
Public functions
areCompatible
fun areCompatible(slotId: Any?, reusableSlotId: Any?): Boolean
Returns true if the content previously composed with reusableSlotId is compatible with the content which is going to be composed for slotId. Slots could be considered incompatible if they display completely different types of the UI.
getSlotsToRetain
fun getSlotsToRetain(slotIds: SubcomposeSlotReusePolicy.SlotIdsSet): Unit
This function will be called with slotIds set populated with the slot ids available to reuse. In the implementation you can remove slots you don't want to retain.