Zach Klippenstein (he/him) [MOD]
07/28/2020, 9:23 PMsavedInstanceState
? Looks like it’s stuck around for now?Leland Richardson [G]
07/28/2020, 9:33 PMstate
: savedInstanceState
:: remember
: rememberSavedInstanceState
rememberSavedInstanceState
rememberSavedInstanceState { mutableStateOf(0) }
would get an autosaver that would “just work”brandonmcansh
07/28/2020, 9:37 PMZach Klippenstein (he/him) [MOD]
07/28/2020, 9:39 PMrememberSavedInstanceState
is a little weird to me conceptually. Why would I care about saving an immutable value? The kdoc explanation about mutable values makes more sense, but for rememberSavedInstanceState { mutableStateOf(0) }
, you’d need to always wrap your custom Saver
in one that unwraps/wraps the MutableState
value, right? That’s a bit awkward.State
or MutableState
, and automatically wraps the Saver
would solve that.state
seems so common and small that I’m a little disappointed to see it go away, although I completely understand the desire to minimize the amount of magic and the API surface, and this is probably a lot simpler to educate.Leland Richardson [G]
07/28/2020, 9:46 PMstate
API so strongly that you’d have to pry it from my cold dead fingersstate
API actually isremember
is the real fundamental API that people need to understandremember
, they might miss the fact that state
is just a convenient call to remembermutableStateOf
can be used outside of compositionZach Klippenstein (he/him) [MOD]
07/28/2020, 9:49 PMLeland Richardson [G]
07/28/2020, 9:49 PM@Composable fun SomeClass() = remember { SomeClass(SomeAmbient.current) }
remember
to hammer in the point@Composable fun rememberSomeClass() = …
@Composable fun SomeClass() = SomeClass(SomeAmbient.current)
Zach Klippenstein (he/him) [MOD]
07/28/2020, 9:55 PMLeland Richardson [G]
07/28/2020, 9:55 PMTimo Drick
07/28/2020, 10:14 PMLeland Richardson [G]
07/28/2020, 10:40 PMlazy
is the right term to use here. i’m actually quite happy with the name of remember
but maybe others feel differently?Timo Drick
07/28/2020, 11:40 PMbrandonmcansh
07/29/2020, 12:01 AMZach Klippenstein (he/him) [MOD]
07/29/2020, 12:09 AMremember
initializes the value (invokes the lambda) eagerly/synchronously. The lazy
delegate doesn’t initialize the value until it’s read (i.e., lazily). Like the lazy
delegate, Lazy*Items
doesn’t add its children to the composition until they’re scrolled into view.Timo Drick
07/29/2020, 12:12 AMbrandonmcansh
07/29/2020, 12:19 AMandylamax
07/29/2020, 1:36 AMLazy*Items
has been bugging me so much. @Zach Klippenstein (he/him) [MOD]'s explanation has made it so clear to me. ThanksZach Klippenstein (he/him) [MOD]
07/29/2020, 1:38 AMRecyclerView
is such a weird name, when you think about it – the main feature of RecyclerView
is that it’s lazy. The fact that it recycles views is just an optimization to reduce memory usage and allocations. It doesn’t have anything to do with its core functionality. I like the Lazy*Items
name a lot better, since it highlights the main feature/use case.Leland Richardson [G]
07/29/2020, 1:54 AMZach Klippenstein (he/him) [MOD]
07/29/2020, 1:58 AMhttps://media.giphy.com/media/jUwpNzg9IcyrK/giphy.gif▾
Leland Richardson [G]
07/29/2020, 1:59 AMandylamax
07/29/2020, 2:00 AMgildor
07/29/2020, 2:54 AMstate{}
function to get rid of boilerplateZach Klippenstein (he/him) [MOD]
07/29/2020, 3:13 AMgildor
07/29/2020, 3:16 AMremember { mutableStateOf(…) }
, alt + enter, extract to a function and forget about it next minute (or maybe it will remember only one developer in the project who introduced this extension)rememberState { … }
would be probably betterLeland Richardson [G]
07/29/2020, 4:27 AMrememberState
remember
and mutableStateOf
gildor
07/29/2020, 5:44 AMmuch harder for us to remove an APIMaybe use OptIn annotation, same as Kotlin stdlib does
andylamax
07/29/2020, 5:45 AMgildor
07/29/2020, 5:47 AM