CachedProperty

class CachedProperty<out T : Any, out E : Any>(instance: E, hint: CachedProperty.CacheHint, maker: E.() -> T)

Implementation of cached read-only property which based on another object.

Author

Alexander Kornilov (akornilov.82@gmail.com).

Parameters

instance

a tracked object. If instance implements StateTrackable interface the StateTrackable.revision will be used; Any.hashCode otherwise.

hint

a some CacheHint for cache strategy.

maker

a maker of a value which holds in a property.

Constructors

CachedProperty
Link copied to clipboard
fun <out T : Any, out E : Any> CachedProperty(instance: E, hint: CachedProperty.CacheHint = CacheHint.None, maker: E.() -> T)
a tracked object.

Types

CacheHint
Link copied to clipboard
enum CacheHint : Enum<CachedProperty.CacheHint>
A cache hint variants.

Functions

getValue
Link copied to clipboard
operator fun getValue(obj: Any, prop: KProperty<*>): T
Returns the cached value of the property.

Properties

currentValue
Link copied to clipboard
var currentValue: T? = null
maker
Link copied to clipboard
val maker: E.() -> T
a maker of a value which holds in a property.