Vaibhav Jaiswal
03/01/2024, 1:13 PMFeedPostItem(
post = it,
modifier = Modifier.fillMaxWidth(),
onAction = component::handlePostAction
)
Arkadii Ivanov
03/01/2024, 1:22 PMonAction = remember(component) { component::handlePostAction }
. But I strongly advice to avoid premature optimisations, unless you have measuarable performance issues. Re-composition itself doesn't imply re-rendering, and it's usually OK to recompose even on every animation frame. Your composables inside FreePostItem
should be still skipped if their state has not been changed.Vaibhav Jaiswal
03/01/2024, 1:28 PMVaibhav Jaiswal
03/01/2024, 1:30 PMArkadii Ivanov
03/01/2024, 1:33 PMVaibhav Jaiswal
03/01/2024, 1:34 PMVaibhav Jaiswal
03/01/2024, 1:34 PMDjuro
03/01/2024, 1:36 PMVaibhav Jaiswal
03/01/2024, 1:42 PMDjuro
03/01/2024, 1:44 PMpost
stable?Djuro
03/01/2024, 1:45 PMVaibhav Jaiswal
03/01/2024, 1:45 PMPost
is stable, all field are val
and of Stable typeDjuro
03/01/2024, 1:58 PMVaibhav Jaiswal
03/01/2024, 2:03 PMArkadii Ivanov
03/01/2024, 2:30 PMFeedPostItem
can still recompose if the outer (containing) function also recomposes for whatever reason (e.g. if there is val state by component.state.subscribeAsState()
in there). But the point is that the re-composition should stop quickly somewhere inside FeedPostItem
- any composables called inside FeedPostItem
with fully stable and unchanged parameters should be skipped. It might be worth extracting something to separate functions with stable arguments.Arkadii Ivanov
03/01/2024, 2:30 PMDjuro
03/07/2024, 10:20 AM