trashcoder
04/07/2022, 8:57 PMSlider position in a variable like this:
var shutterLevel by remember { mutableStateOf(shutter.shutterLevel) }
And in the onValueChangeFinished event, I pass it to the API to control the device.
This all works as expected, but... I also listen to events from the server. So whenever the brightness is changed through another app or the shutter level is modified with the wall switch, the Slider position does not change because it was `remember`ed.
I would be really happy if anyone could help me understand what I am missing here.tad
04/07/2022, 9:05 PMState variable, so that's what it will use.
I would read up on state hoisting so you can have a common source of truth that is updated from both your Composable function and whatever external event you are observing.trashcoder
04/07/2022, 9:22 PMSlider. Maybe I should further investigate the "Laggyness" then. Thanks!tad
04/07/2022, 9:27 PMkey argument to remember, e.g. remember(shutter.shutterLevel) { mutableStateOf(shutter.shutterLevel) }tad
04/07/2022, 9:28 PMshutter to update itself directly in onValueChangeFinishedtrashcoder
04/07/2022, 9:35 PMkey to remember and now it works! mind blown
Thanks a lot! 🥳 🙏tad
04/07/2022, 9:36 PM