Is there a way to directly react to changes from a...
# compose-desktop
m
Is there a way to directly react to changes from a "State" like e.g. the DatePickerState? I would want something like a onDateSelect lambda for simplicity
a
Copy code
val state = rememberDatePickerState()

LaunchedEffect(state, onDateSelected){
    snapshotFlow {
        state.selectedDateMillis
    }.collect { millis ->
        onDateSelected(millis)
    }
}
m
Thanks!
z
One tweak to that would be to put your onDateSelected lambda in something like a rememberUpdatedState so you don’t have to restart the effect if a different callback is passed (which will fire that callback immediately for the current value) - unless that’s the behavior you want.