Slide 69
Slide 69 text
2022
찰스의 안드로이드
컨퍼런스
Snapshot System
1
🖨
20
📸 12
1
1 10 12
11220
merge!
fun main() {
var age by mutableStateOf(
value = 1,
policy = object : SnapshotMutationPolicy {
override fun equivalent(a: Int, b: Int) = a == b
override fun merge(previous: Int, current: Int, applied: Int) =
"$previous$current$applied".toInt()
}
)
// ...
snap1.enter {
age = 10
age = 12
}
snap1.apply()
snap2.enter {
age = 20
}
snap2.apply()
println(age) // 11220 (previous: 1, current: 12, applied: 20)
}