Open matejdro opened 2 years ago
Wire doesn't generate data class
es.
The annotation works on any type
Not sure if this is really possible. If this feature is enabled, it will be possible to draw the contents of the protobuf in Compose. For example, using Zipline and Molecule, we would be able to use protobufs to create the content we want to display in the UI and then display it in the UI. The reason why we want to use protobuf is to ensure compatibility between versions. It would be best to share a design system like Redwood, but I personally find it a bit daunting.
The right fix here is to contribute our base class to the Compose compiler in the list of implicitly stable/immutable types.
Thanks for your advice. I think we can add com.squareup.wire.Message
here. The method for it is already there. 👀
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/analysis/Stability.kt;l=222?q=stableTypes&ss=androidx%2Fplatform%2Fframeworks%2Fsupport
Perhaps the person reporting that this type is stable/immutable should not be an outsider like me. The reason is that reviewers cannot decide whether they should believe me or not.
Interesting, that'd be sweet to get it in.
I think it is really interesting to be able to do something like a server driven UI while having state within the client.
@oldergod Could you provide the Message type to AOSP? Let me know if there is anything I can do to help.
I've created a change. Let's see how it goes.
https://android-review.googlesource.com/c/platform/frameworks/support/+/2456088
Update: The above PR is now closed.
Related: #2794
But on top of that, since Compose compiler 1.5.5
, one can locally configure stable types as so:
plugins.withId("org.jetbrains.compose") {
tasks.withType<KotlinCompile> {
val configPath = rootDir.resolve("my_compose_compiler_config.conf").path
compilerOptions.freeCompilerArgs.addAll(
"-P", "plugin:androidx.compose.compiler.plugins.kotlin:stabilityConfigurationPath=$configPath",
)
}
}
And my_compose_compiler_config.conf
would be
com.squareup.wire.Message
com.squareup.wire.WireEnum
When displaying UI using Jetpack Compose, data model must have
@Immutable
annotation to achieve the best performance: https://developer.android.com/reference/kotlin/androidx/compose/runtime/ImmutableCould you add an option to include such annotation on all generated wire classes?