takahirom
03/25/2022, 11:03 AM@Composable
fun Composable1(articles: Articles) {
Text(text = "Hello $articles!")
}
@Stable
data class UiModel(val articles: Articles)
@Composable
fun Composable2(uiModel: UiModel) {
Text(text = "Hello $uiModel!")
uiModel.articles.articles.forEach {
Composable3(it)
}
}
@Composable
fun Composable3(article: Article) {
Text(text = "Hello $article!")
}
model module
data class Articles(val articles: List<Article>)
data class Article(val title: String)
app_release-composables.txt
restartable fun Composable1(
unstable articles: Articles
)
restartable skippable fun Composable2(
stable uiModel: UiModel
)
restartable fun Composable3(
unstable article: Article
)
source code
https://github.com/takahirom/compose-multi-module-stabilityritesh
03/25/2022, 11:38 AMdata class Article(val title: String)
is unstableritesh
03/25/2022, 11:38 AMdata class Articles(val articles: List<Article>)
This is unstable because List
isAlbert Chang
03/25/2022, 1:00 PMshikasd
03/25/2022, 4:48 PMmyanmarking
03/25/2022, 5:48 PMmyanmarking
03/25/2022, 5:51 PMmyanmarking
03/25/2022, 5:51 PMmyanmarking
03/25/2022, 5:52 PMtakahirom
03/26/2022, 2:02 AM@Stable
class that has Compose's Compiler applied to it.
https://github.com/takahirom/compose-multi-module-stability/commit/a4a1a34ec769a8524309a2205f43b8f28ce6e633#diff-14e800d090d55[…]dd4bae3552a9e209bL1Tash
07/12/2023, 10:20 PMandroidx.compose.ui:ui:1.4.3
. Does not have compose buildFeature
enabled/no compose compiler plugin
◦ We define interface MutableData
with @Immutable
annotation in this module
• App module depends on this lib module. App module has compose/compose compiler 1.4.6
enabled
• App module defines _data class_ ViewState(_val_ a: Int, _val_ b: _MutableData_)
• Running Compose Compiler Metrics for release flavor in app module gives us this:
With @Immutable
on `interface MutableData`:
stable class ViewState {
stable val a: Int
stable val b: MutableData
<runtime stability> = Stable
}
Without @Immutable
on `interface MutableData`:
unstable class ViewState {
stable val a: Int
unstable val b: MutableData
<runtime stability> = Unstable
}
Has something changed since this convo happened and the article was published? cc @takahirom since you wrote up the article (which is great btw, thank you for that!)takahirom
07/27/2023, 1:48 AM