CachedProperty

class CachedProperty<KEY : Any, VALUE>(val keyProperty: () -> KEY, lazy: Boolean = false, val factory: (KEY) -> VALUE) : ReadOnlyProperty<Any?, VALUE>

Caches a property value until a key changes.

Parameters

keyProperty

Function that provides the latest value of the cache key.

lazy

Whether to initialize the value immediately, or upon first invocation.

factory

Function to create the property value based on its current cache key.

Constructors

Link copied to clipboard
fun <KEY : Any, VALUE> CachedProperty(keyProperty: () -> KEY, lazy: Boolean = false, factory: (KEY) -> VALUE)

Functions

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): VALUE

Properties

Link copied to clipboard
val factory: (KEY) -> VALUE
Link copied to clipboard
val keyProperty: () -> KEY