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

Follow Recommended Practices when Using Data classes along with Compose #26

Merged
merged 2 commits into from
Aug 25, 2023

Conversation

avidraghav
Copy link
Owner

No description provided.

@avidraghav
Copy link
Owner Author

Creating a field in a data class like val reminders: ImmutableList<Reminder> = persistentListOf() is not considered stable by the Compose Compiler
Only giving type creates no issues such as val reminders: ImmutableList<Reminder> is considered stable

for e.g. the compose compiler metric output for the

@Stable
data class RemindersScreenState(
    val reminders: ImmutableList<Reminder> = persistentListOf(),
    val isLoading: Boolean = false,
    val infoMessage: String? = null
)

is:

stable class RemindersScreenState {
  runtime val reminders: ImmutableList<Reminder>
  stable val isLoading: Boolean
  stable val infoMessage: String?
}

This issue is known to exist see: persistentListOf & compose compiler issue

@avidraghav avidraghav merged commit 1fcdf23 into main Aug 25, 2023
3 checks passed
@avidraghav avidraghav deleted the feature/compose_performance_improvement branch August 25, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant