Makes a cache for Media Items

This commit is contained in:
Vitor Pamplona
2024-03-26 11:56:10 -04:00
parent b45f9bd460
commit cd32c4db72
2 changed files with 85 additions and 78 deletions

View File

@@ -35,6 +35,17 @@ fun <K, V> produceCachedState(
}
}
@Composable
fun <K, V> produceCachedState(
cache: CachedState<K, V>,
key: String,
updateValue: K,
): State<V?> {
return produceState(initialValue = cache.cached(updateValue), key1 = key) {
value = cache.update(updateValue)
}
}
interface CachedState<K, V> {
fun cached(k: K): V?