kite-core / jp.co.cyberagent.kite.core / memo
memo¶
fun <T>
KiteDslScope
.memo(computation:
KiteMemoScope
.() ->
T
):
KiteState
<
T
>
Evaluate the computation during the computation. The evaluation result will be cached into a KiteState.
Usage:¶
val myState = state { 0 }
launch {
for(i in 0..10) {
delay(1000)
myState.value++
}
}
// myMemo value will changed with 0, 2, 4, ..., 20
val myMemo = memo {
myState.value * 2
}