https://kotlinlang.org logo
#compose
Title
# compose
e

eygraber

01/17/2023, 10:33 PM
Anyone experiencing a BackendException with a composable getter and not finding
remember
? - https://issuetracker.google.com/issues/265824770
a

Albert Chang

01/18/2023, 1:42 AM
You can only call composable functions that are marked with
ReadOnlyComposable
in a
ReadOnlyComposable
function. However,
collectAsState()
is not marked with
ReadOnlyComposable
. From the doc of `ReadOnlyComposable`:
This is not safe unless the body of the function and any functions that it calls only executes "read" operations on the passed in composer.
remember
is a "write" operation because it stores the value into the composer's slot table.
I'm not sure if this is the cause of the exception but your code is definitely wrong.
e

eygraber

01/18/2023, 1:46 AM
I refactored and removed the
remember
. But first I tried taking out
ReadOnlyComposable
and the exception still happens. It was weird because I usually get a warning in the IDE about using
ReadOnlyComposable
and calling something that doesn't, but that wasn't there. Maybe because it was a property
z

Zach Klippenstein (he/him) [MOD]

01/18/2023, 4:22 PM
What if you apply the Composable annotation to the property, instead of just the getter
4 Views