altavir
09/13/2022, 3:26 PMvar cachedValue by remember { mutableStateOf(initialViewPoint) }
var viewPoint by remember { mutableStateOf(initialViewPoint) }
if (cachedValue != initialViewPoint) {
viewPoint = initialViewPoint
cachedValue = initialViewPoint
}
Zoltan Demant
09/13/2022, 3:42 PMkey(value){}
around your content, whenever value changes then the inner remember, etc, will be reset as if it was the first time it was invoked.altavir
09/13/2022, 3:47 PMremember(initialViewPoint){}
and it is very strange because it does not reset the value, but instead changes the way the value is visible in some strange way. The value is different for different functions inside the composable. Maybe it is some kind of bug in compose-desktop since I am using dev version.Zoltan Demant
09/13/2022, 3:56 PMcachedValue
, viewPoint
, alongside however you make use of them, inside the key(){}
block?
As an alternative to all of this, I guess you could also specify initialViewPoint as the key for the remember calls so that they reset whenever it changes.altavir
09/13/2022, 3:59 PMshaktiman_droid
09/13/2022, 4:06 PMThere are no silly questions!
Zoltan Demant
09/13/2022, 4:08 PMkey(viewPoint) { MapView(...) }
block instead. Given that its not actually a bug (or me simply misunderstanding key completely 😅) that should give you the behavior youre looking for as well.altavir
09/13/2022, 4:10 PMaltavir
09/13/2022, 4:13 PM