Is there an existing cached computed property patt...
# announcements
s
Is there an existing cached computed property pattern in Kotlin? For example:
Copy code
var firstName: String = "Charlie"
var lastName: String = "Brown"
val fullName: String by lazy {
  "$firstName $lastName"
}
println(fullName) // Charlie Brown

firstName = "Snoopy"
// Let "fullName" know it will need to recompute the next time it is accessed
println(fullName) // Snoopy Brown
I’m currently going down writing my own
ReadWriteProperty
for it but wondering if there is an existing pattern for this already? Thanks!
a
compose has this:
Copy code
var firstName by mutableStateOf("Charlie")
var lastName by mutableStateOf("Brown")
val fullName by derivedStateOf { "$firstName $lastName" }
🤯 2
s
Thanks! I’ll check that out.
👍 1