Timo Drick
01/27/2021, 11:20 AMjim
01/27/2021, 11:24 AMDisposableEffect
without a key would be rare, and would love to see details about any counterexample.
With regards to your specific question though, I believe you can just pass in Unit
as the key parameter, which will satisfy the compiler.Unit
looks awkward is very intentional, goal is to get a code reviewer to be like 😬 (and hopefully ask questions) when they see it.Timo Drick
01/27/2021, 11:28 AMAdam Powell
01/27/2021, 3:11 PMSideEffect
.Timo Drick
01/27/2021, 3:16 PMval ts = remember { CrosstransitionState<SavedStateData<T>>() }
DisposableEffect(transition) {
ts.newTarget(transition.data)
...
ts.scope?.invalidate()
onDispose {
}
}
Adam Powell
01/27/2021, 3:22 PMval ts = remember { ... }
SideEffect {
ts.target = transition.data
}
setting target
should skip if the new value is equal or invalidate as necessaryTimo Drick
01/27/2021, 3:24 PMAdam Powell
01/27/2021, 3:26 PMTimo Drick
01/27/2021, 3:26 PMAdam Powell
01/27/2021, 3:27 PMonCommit
to observe a snapshot state object for changes to run some code when it does change, then you've encountered the antipattern that this API change was intended to break/make very awkward 🙂onCommit
that way is that it forces recomposition of its surroundings to dispatch an event callback, and it does so by waiting for a composition frame.Timo Drick
01/27/2021, 3:30 PMAdam Powell
01/27/2021, 3:31 PMval ts = remember { ... }
LaunchedEffect(ts) {
snapshotFlow { transition }.collect { newTransitionValue ->
ts.newTarget(newTransitionValue.data)
// ...
}
}
Timo Drick
01/27/2021, 3:32 PMAdam Powell
01/27/2021, 3:33 PMTimo Drick
01/27/2021, 3:34 PMval ts = remember { ... }
if (ts.target != transition.data) {
ts.target = transition.data
}
Adam Powell
01/27/2021, 3:37 PMTimo Drick
01/27/2021, 3:44 PM