Is it OK to use `@ReadOnlyComposable` if the funct...
# compose
e
Is it OK to use
@ReadOnlyComposable
if the function only reads a
State
value?
s
Considering that the comment above it says:
Copy code
This annotation can be applied to Composable functions so that no group will be generated around the body of the function it annotates. 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. This will result in slightly more efficient code.
A common use case for this are for functions that only need to be composable in order to read CompositionLocal values, but don't call any other composables.
And reading from a CompositionLocal, which is the common use case of using this annotation, is exactly doing what you are saying, reading something from state it sounds like this should be perfectly fine. With that said, how does that function even look like if not reading from a composition local? Do you pass in a
State
object as a parameter?
e
It's basically a wrapper around a state that I'm using to break up ViewModels business logic