---
title: "SubcomposeSlotReusePolicy"
description: "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."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
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.


## Functions

```kotlin
fun getSlotsToRetain(slotIds: SlotIdsSet)
```


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.


```kotlin
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.



