Is there a way to get the marker annotations (particularly
@Immutable
) in a separate, common artifact? I have some data definitions in a common module that doesn't have compose dependencies, and would like to mark them as immutable.
j
jw
04/10/2021, 4:53 AM
Define your own in common with
@OptionalExpectation
and then
actual typealias
in the Android source set
r
rnett
04/10/2021, 5:59 AM
Unfortunately my compose module is entirely separate from the multiplatform module and consumes it via a dependency, so I don't have access to
@Immutable
even on the jvm source set. I could add the compose runtime as a dependency there and do it, but it's rather big and there should be an easier way imo.
a
Albert Chang
04/10/2021, 3:48 PM
I doubt if it will work without applying the compose compiler plugin. I don't think the compiler takes annotations of classes in other modules into account.
z
zalewski.se
04/10/2021, 7:22 PM
@rnett
In such case, what if you would create
typealias
(that points to your state data class) in the module where you have compose and then annotate this
typealias
with
@Immutable
? Later you just pass your state to Composable fun