myanmarking
09/28/2021, 1:47 PMAdam Powell
09/28/2021, 1:57 PMif (condition) {
LaunchedEffect...
myanmarking
09/28/2021, 1:58 PMAdam Powell
09/28/2021, 1:59 PMmyanmarking
09/28/2021, 2:00 PMAdam Powell
09/28/2021, 2:00 PMif (condition) {
Text("condition is true!")
}
myanmarking
09/28/2021, 2:01 PMmyanmarking
09/28/2021, 2:01 PMLaunchedEffect(key1 = Unit) {
while (true) {
delay(autoScrollInterval)
state.animateToNextPage()
}
}
myanmarking
09/28/2021, 2:01 PMmyanmarking
09/28/2021, 2:02 PMmyanmarking
09/28/2021, 2:03 PMif (autoScroll.value) {
LaunchedEffect(key1 = Unit) {
while (isActive) {
delay(autoScrollInterval)
state.animateToNextPage()
}
}
}
Zach Klippenstein (he/him) [MOD]
09/28/2021, 2:29 PMstate
. This is more correct because if the value of state
changes between compositions, it doesn't make sense for the effect to continue executing on the old state.
For autoScrollInterval
, if the interval changes while scrolling, you probably don't want to cancel the current scroll, but rather just use the new interval for the next iteration, so it's better to use rememberUpdatedState
and not pass it as a key.myanmarking
09/28/2021, 6:02 PM