Hello, trying to achieve a Todo List in Compose, h...
# compose
l
Hello, trying to achieve a Todo List in Compose, however, when I create a
@Model
class which has a list, adding elements to that list don’t trigger the drawing of the model on the screen. In order to have it working I added a
counter
to that model class. Increasing that
counter
whenever I add something to the list triggers the drawing of the model on the screen. (https://gist.github.com/lnicolet/039d2fe76e19e859582e32625ac411e7, https://gist.github.com/lnicolet/cb49c5a4021efc3b784bf95ec5755321). Working and not working examples in the links. Is there a different way to have it working with
lists
?
t
As far as I know,
@Model
tracks only changes of its properties. You are using
MutableList
, so you don't trigger property setter. Use
List
instead and you will be fine
l
Thanks! Another question, how can I achieve tracking changes on items inside the list itself being propagated to the class which wraps the list? E.g.: changing the
isDone
to trigger an update
s
Not sure, but you can try to use
@Model
on such classes as well.
l
I am already 🙂
t
@Luca Nicoletti I saw
@Pivotal
annotation does something like this
w
Hey @Luca Nicoletti Did you manage to get your list to work?