Colton Idle
04/24/2020, 1:11 AMLeland Richardson [G]
04/24/2020, 5:55 AMColton Idle
04/24/2020, 6:52 AMBrian Gardner
04/24/2020, 2:18 PMLeland Richardson [G]
04/27/2020, 9:01 PMmutableStateOf(...)
where you used it instead of state { ... }
. The latter seems more correct based on the usage.Ryan Mentley
04/27/2020, 9:02 PMBrian Gardner
04/27/2020, 9:03 PMLeland Richardson [G]
04/27/2020, 9:04 PMstate
though.Brian Gardner
04/27/2020, 9:04 PMmutableStateOf()
work differently than state
?Leland Richardson [G]
04/27/2020, 9:06 PMmutableStateOf
is like a constructor, and will create a new instance each time (with the value you pass in). The state
function is a composable function which will only execute the init
lambda the first time, and it will remember the instance each time. when creating state ina composable function, this is usually what you want. it is basically shorthand for remember { mutableStateOf(init()) }
Ryan Mentley
04/27/2020, 9:07 PMmutableStateOf
in the preview, I think, is the one that probably should lost be state
Brian Gardner
04/27/2020, 9:08 PMremember{}
block inside the composable function?Ryan Mentley
04/27/2020, 9:09 PMMutableState
directly like this? https://github.com/BrianGardnerAtl/JetpackComposePlayground/blob/adapter-list-state-spike/app/src/main/java/tech/briangardner/composeplayground/MainActivity.kt#L58Leland Richardson [G]
04/27/2020, 9:09 PMRyan Mentley
04/27/2020, 9:09 PMLeland Richardson [G]
04/27/2020, 9:10 PMBrian Gardner
04/27/2020, 9:10 PMRyan Mentley
04/27/2020, 9:11 PMLeland Richardson [G]
04/27/2020, 9:11 PMBrian Gardner
04/27/2020, 9:13 PMLeland Richardson [G]
04/27/2020, 9:17 PMBrian Gardner
04/27/2020, 9:20 PMLeland Richardson [G]
04/27/2020, 9:22 PMBrian Gardner
04/27/2020, 9:23 PMLeland Richardson [G]
04/27/2020, 9:23 PMonCommit
to do it properlyBrian Gardner
04/27/2020, 9:24 PMLeland Richardson [G]
04/27/2020, 9:25 PMBrian Gardner
04/27/2020, 9:25 PMonCommit
or onActive
too much so I’ll look into those nextLeland Richardson [G]
04/27/2020, 9:26 PMstate
and see if that fixes the adapterlist bug you filed?Brian Gardner
04/27/2020, 9:27 PMstate
worksLeland Richardson [G]
04/27/2020, 9:28 PM