https://kotlinlang.org logo
#compose
Title
# compose
m

MBegemot

05/12/2020, 12:01 PM
This is one of my two screens, when first launched , as statusApp.lang has just been initialized the getListHeadlines is called, if I change the statusApp.fontSize, the headlines are redrawn but the headlines are not loaded which is what I want, but If I go to the next screen which is a detail screen, when I came back by pressing the back button and assigning the application screen to be again the headlines screen, I've got the elements reloaded as if stattusApp.lang would have changed.
a

Adam Powell

05/12/2020, 12:45 PM
Looks like you're mutating the list held by the
state
but not the
state
itself. The code above is roughly equivalent to
var list = mutableListOf(...)
but compose only knows when you change the
var
, not its contents.
Try
remember { modelListOf(...) }
Or use read-only or immutable lists as the value of the
State
Rather than having both the list reference and the list itself both mutable
modelListOf
will give you a mutable list where compose is tracking its content changes
m

MBegemot

05/12/2020, 1:19 PM
Well, I'm sure I'm doing it wrong, but is almost fascinating how far you can go wrong, I've got exactly what I want except that oddity on the backpress. I've found the information on state and effects to be rather scarce , and it looks some times that you have more than one option to obtain the same thing and that's confusing ... But I want to highlight that with all it's oddities I'm very satisfied with the results, I have just one file 500 lines and the equivalent in regular android would have been vastly more cumbersome.
🙂 2