Sam
11/12/2020, 11:01 PMval countries by remember { listOf(Locale.getISOCountries().map { Locale("", it) }) }
with exception: Type 'TypeVariable(T)' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
Ian Sikes
11/12/2020, 11:02 PMmutableListOf
?Sam
11/12/2020, 11:03 PMremember
but i can't find any examplesIan Sikes
11/12/2020, 11:07 PMmutableStateListOf
? haha I haven't quite got it either. The codelabs seem to cover mutableStateOf
but not these other usesZach Klippenstein (he/him) [MOD]
11/13/2020, 12:28 AMmutableStateOf
returns a MutableState
, which has getValue
(and setValue
) defined as extension functions, which is why that works.remember
just returns whatever you return from the lambda – it doesn’t change the type. So if what you’re returning can’t act as a delegate, this won’t work.Sam
11/13/2020, 12:29 AMmutableStateOf
even for lists?Zach Klippenstein (he/him) [MOD]
11/13/2020, 12:29 AMList
nor SnapshotStateList
can be delegatesso is the solution to use mutableStateOf even for lists?Yes, the list is your state here.
=
instead of by
.Sam
11/13/2020, 12:31 AMZach Klippenstein (he/him) [MOD]
11/13/2020, 12:32 AMremember
lambda will only be executed once