I want to trigger a callback when a `LazyColumn` i...
# compose
s
I want to trigger a callback when a
LazyColumn
item becomes visible for only once. It shouldn't trigger if a user moves up and down the list. The problem I am facing is that irrespective of which side effect I use any time a Composable from down the list becomes visible, it seems, starts a new composition which means the side effect gets triggered when a user moves up or down the list. Is there a way to avoid this situation? I had asked my question here on SO. So far, the only way to handle this situation for me would be holding a variable in the data class (
isSeen: Boolean
).
j
You can handle this state in viewModel or on a remember function. For example:
val isVisibleAtFirts by remember { mutableStateOf(false)
You can use LazyListLayoutInfo to get item visibility on screen, and when item is visible, just set variable to true