How can I mark LocalDate, LocalDateTime and Local...
# compose
a
How can I mark LocalDate, LocalDateTime and LocalTime immutable so compose can skip them when they haven't changed?
j
You have to either create a wrapper over those, like this:
Copy code
@Stable
data class StableHolder<T>(val value: T)

fun <T : Any> T.wrapAsStable(): StableHolder<T> {
    return StableHolder(this)
}
Or you can directly mark you ui models as @Stable
either way you have to have some class that is holding a field with those types and this class have to be explicitly marked as stable/immutable
a
Thank you.
Also, it would be better if Google can provide another way like proguard rules to mark these class😂
j
Agree, there is quite a big topic around that at google bugtracker
s
Yeah, or they’d need to somehow be convinced to have more such 3rd party objects marked as stable by them. Like they did with
kotlinx.collections.immutable.ImmutableList
and so on. But either way, I don’t see that happening very soon.