Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Compose stability #5732

Open
BoD opened this issue Mar 15, 2024 · 3 comments
Open

Handle Compose stability #5732

BoD opened this issue Mar 15, 2024 · 3 comments

Comments

@BoD
Copy link
Contributor

BoD commented Mar 15, 2024

The models generated by Apollo Kotlin are immutable, and therefore should participate in skipping recomposition. However list fields are generated with List<T> which is considered unstable by Compose.

More information about Compose stability here.

We could mark the generated models with @Immutable but that implies with a dependency to androidx.compose.runtime:runtime, so we would need to make this configurable

In the meantime users can already mark the generated models as stable manually with the Compose compiler configuration file

  • globally if they are generated in a dedicated package (com.example.models.**)
  • by adding all models individually (albeit this is tedious and error-prone)
@StylianosGakis
Copy link
Contributor

I wonder if you should just rely on strong-skipping mode instead https://medium.com/androiddevelopers/jetpack-compose-strong-skipping-mode-explained-cbdb2aa4b900 and not have to worry about doing such optimizations on the apollo-kotlin end.
My understanding is that strong skipping will be enabled by default in the future and as long as the generated models generate proper .equals functions, which they do, then it might just be fine to not do anything here

@BoD
Copy link
Contributor Author

BoD commented Apr 19, 2024

Thanks a lot for sharing, interesting stuff! From what I gather, it sounds like with this change, stability won't be as important as it was.

It still doesn't hurt and is pretty easy to mark all generated classes as stable with the configuration file. Maybe this ticket is just to document how to do this somewhere in our docs.

@StylianosGakis
Copy link
Contributor

Yeah that is fair, as long as you do not mind having the annotation in the sources, and you anyway guarantee that those classes are immutable, then adding the annotation is also safe enough that it shouldn't matter.

But I agree with keeping the ticket open. Strong skipping mode isn't on by default yet anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants