computed On
inline fun <E : Event, V> EventListener.computedOn(initialValue: V, priority: Short = 0, crossinline accumulator: (event: E, prev: V) -> V): ReadWriteProperty<EventListener, V>
Returns computed ReadWriteProperty based on the accumulator of specific event.
The value of property will be updated on event received with accumulator.
Example:
var ticksSinceEnabled by computedOn<GameTickEvent, Int>(0) { _, prev -> prev + 1 }
fun enabled() { ticksSinceEnabled = 0 }Content copied to clipboard
Author
MukjepScarlet
Since
0.30.1