Quick question: What is `@ReadOnlyComposable` ?
# compose
m
Quick question: What is
@ReadOnlyComposable
?
h
This composable has no (write) effects, which does not trigger a recomposition, so it (and its children if any) can't host a
State
. BTW the docs are nice to read :)
z
It doesn't have anything to do with snapshot state. The docs say all this, but it can only do reads, not writes. Writes are things like calling
remember
or other non-readonly composables (which, even if they don't actually write, the compiler won’t know if they're not similarly annotated).
l
its less about the compiler not being able to tell and more about declaring it as a guarantee you are willing to provide across versions as part of your public api so that the optimization doesnt break whrn the function gets refactored to make writes but the calling module doeant get recompiled.
but yeah, its about reads/writes to the slot table, not to snapshots
n
FYI, a related good book is available: https://leanpub.com/composeinternals
442 Views