:wave: How should I listen for value changes on `A...
# compose-android
n
👋 How should I listen for value changes on
AnchoredDraggable
? Can
currentValue
be observed as
State
? I know there’s a callback in the constructor named
confirmValueChange
but if I want to manipulate the state itself on that callback, things get messy.
s
Is
currentValue
a mutableState under the hood? If yes you can just do a snapshotFlow on it
n
It is, yes.
s
snapshotFlow { x.currentValue }.collectLatest { ... }
Then should be what you want
n
Ouhkay, let me try that. Thanks!
s
Do it inside a LaunchedEffect, keyed on the state object itself probably is the most safe way to go about it.
n
Sounds good, thanks!
j
Yes,
snapshotFlow
(usually in a
LaunchedEffect
) is the recommended way
n
Thank you ✌️