https://kotlinlang.org logo
Title
m

Mjahangiry75

05/15/2022, 5:32 PM
Quick question: What is
@ReadOnlyComposable
?
h

hfhbd

05/15/2022, 5:57 PM
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

Zach Klippenstein (he/him) [MOD]

05/15/2022, 8:34 PM
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

Leland Richardson [G]

05/16/2022, 1:58 PM
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

Norbi

05/17/2022, 10:43 AM
FYI, a related good book is available: https://leanpub.com/composeinternals