Resettable

class Resettable<T>(default: () -> T)

A property delegate that instruments resetting it between opmode runs.

This is used in delegate properties. You must pass a function when constructing the resettable property that returns its default value.

Example

object MyAPI : API() {
// The starting value of someState is 10.
private var someState: Int by Resettable { 10 }

fun mutateState() {
// `Resettable` variables can be mutated as normal.
someState = 15
assert(someState == 15)
}
}

Constructors

Link copied to clipboard
constructor(default: () -> T)

Functions

Link copied to clipboard
operator fun getValue(thisRef: Any?, property: KProperty<*>): T
Link copied to clipboard
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T)