and maps from one object to another. I should be marking it as
@ReadOnlyComposable
?
More in đź§µ
ritesh
03/25/2022, 9:48 AM
Copy code
@Composable
@ReadOnlyComposable
fun SomeSealedClass.toOtherSealedClass(): OtherSealedClass {
return when (this) {
is SomeSealedClass.Something -> OtherSealedClass.Something(label = stringResource(id = this.stringId))
}
}
ritesh
03/25/2022, 10:00 AM
Since this composable will never write to the composition, it can be marked as
ReadOnlyComposable
IMO, to avoid generating groups and all.
t
takahirom
03/25/2022, 12:16 PM
As I recall, a Composable that returns a value should not have a group.
Functions that have a non-unit return value don’t get their own scopes because they can’t be re-executed without also re-executing their caller, so their caller can “see” the new return value computed by the function.
You never need to use these sorts of annotations. But yea if a composable returns a value then I don’t think this particular annotation has any effect anyway.
r
ritesh
03/27/2022, 4:35 AM
Ahh okay, but it will make compose runtime avoid generating groups and all on slot table? As it's not writing to a composition, generating things like those can be avoided, i believe.