dimsuz
09/01/2020, 12:11 PMvar inputState: TextFieldValue by mutableStateOf(TextFieldValue())
fails with an error
Type 'MutableState<TypeVariable(T)>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate
flosch
09/01/2020, 12:12 PMvar inputState: TextFieldValue = mutableStateOf(TextFieldValue())
or var inputState: TextFieldValue by remember { mutableStateOf(TextFieldValue()) }
dimsuz
09/01/2020, 12:13 PMDaniel Sandström
09/01/2020, 12:14 PMandroidx.compose.runtime.getValue
androidx.compose.runtime.setValue
dimsuz
09/01/2020, 12:15 PMflosch
09/01/2020, 12:15 PMflosch
09/01/2020, 12:18 PMremember
cannot be compared.
remember
can be called by delegation (`getValue`/`setValue`), mutableStateOf
cannot.mutableStateOf
, can be called by delegationdimsuz
09/01/2020, 12:21 PMvar todoItems: List<TodoItem> by mutableStateOf(listOf())
no remember and delegation. But it doesn't work when I try to feed TextFieldValue like thisdimsuz
09/01/2020, 12:21 PMby remember { mutableStateOf(...) }
worksflosch
09/01/2020, 12:23 PMremember { X }
, mutableStateOf(X)
and remember { mutableStateOf(X) }
are doing.dimsuz
09/01/2020, 12:24 PMby mutableStateOf
thendimsuz
09/01/2020, 12:25 PMflosch
09/01/2020, 12:25 PMdimsuz
09/01/2020, 12:29 PMby mutableStateOf
simply adjusts property to delegate to state's get/set, then I don't understand why codelab's examples work without remember:
var todoItems: List<TodoItem> by mutableStateOf(listOf())
propagates changes to composables.
While if I do this with TextFieldValue
it isn't propagating. only if I additionaly wrap in remember
— then it does.