I have a question about how to deal with state in ...
# compose
b
I have a question about how to deal with state in an
AdapterList
. If I have actions in the individual row items that should update the view state, I’ve found that using a
MutableState
for the individual row views does not work. I’m guessing this is because even if the row view tries to set its state it still needs the state of the AdapterList to update in order to trigger the recomposition. My question then, is how should the state be updated for the
AdapterList
? In the
itemCallback
of
AdapterList
we only get the item passed to the lambda, not an index. Is it safe to grab the index of the item from within the
itemCallback
to update the list state?
Here’s the code with my current spike branch. I tried moving the state up to the
AdapterList
and updating the state using the index of the items but I’m not seeing the view recompose https://github.com/BrianGardnerAtl/JetpackComposePlayground/tree/adapter-list-state-spike
I tried both updating the list I got when calling
state.value
as well as updating
state.value
directly and neither work
a
If the item composition isn't updating for model/state changes that sounds like it might be a bug in AdapterList
b
Ok, I should be able to file a bug ticket later on today
👍 1
r
Thanks, I'll have a look!