I am trying to set an array of `MovesNavigatorElem...
# compose
l
I am trying to set an array of
MovesNavigatorElement
- which is a class I've defined - as a property of my
@Composable
but it does not compile : more in thread
This is the sealed class
MovesNavigatorElement
This is the code which does not compile.
This is the error.
a
Use
=
instead of
by
👍🏾 1
l
Thank you very much. The compilation has gone. 😃 Now I am facing a different kind of error.
a
Property delegation is the preferred convention for
mutableStateOf
because
MutableState<T>
is essentially a collection of exactly one element and explicitly referring to its
.value
property is cumbersome/noisy. Other snapshot collection types are used as usual elsewhere.
👍🏾 1
l
Thank you, I understand. Also, is using a
SnpashotMutableList
the best way to handle a mutable array of items, in order to save them as a property of Composable, like I'm trying ? Or can I do simpler ?
Finally found that the snapshot can be converted with
.toTypedArray()
.
a
If composition is either a producer or consumer of mutations to this list, a snapshot list is probably the simplest solution.
👍🏾 1
l
Thank you. 😃 I think I've understood. In my current use case, I'm not particularly having Reactive Programming in mind