Can we invoke a function without causing recomposi...
# compose
l
Can we invoke a function without causing recompositions? This causes everything within the current
@Composable
scope to recompose.
Copy code
val boolean by remember {
    derivedStateOf { uiState.offset.value > 0 }
}

stateHolder.handleState(boolean)
this works but feels really bad because it builds a flow every time the key changes and is asynchronous…
Copy code
LaunchedEffect(uiState) {
    snapshotFlow { uiState.offset.value > 0 }
        .onEach { stateHolder.handleState(boolean) }
        .collect()
}
Also, if this is just a really bad idea please let me know 🙂
t
Can you share entire the composable function?
l
I think my issue is caused by something else..
t
If you share the composable function entirely it will be easier to detect the issue.
Because compose compiler is very magic :)))
l
hahah ya I tried to break it down into a very simple example and the same issue didn’t occur
So I think the issue I am seeing is related to something else.. I will keep investigating 🙂
a
If you remove the 'by' and use state.value only in a lambda scope where its needed you can control what composables are getting invoked when the value changes