SwiftUI - List view doesn't get updated even the state gets updated

Hi

I am working on an app which has a list of orders on a view. Order status -received, preparing, ready, complete- gets updated real time via another app. We are using graphql subscription, which order status gets updated, and in my reducer I catch it updated order, and find it in orders array, update with the new order.

What I couldn't figure out is, UI doesn't get updated.

If a new order is created and when I append it, it gets updated.
If an order is completed, and when I remove from array, it gets updated.

However if order is not needed to append or remove, just update then nothing happens even order is updated in the array in the state. I need to leave the page, and come back again to see updated.

I even copied the order to be updated to update its status after updated order comes from catchtoeffect has different id(UUID),
Still didn't work.
I even tried remove at index, and insert at index, still didnt get updated.

What is the best approach for this scenario?
I tried ForEachStore, binding, after 3 days, I started to confuse myself.

Which example in the SCA case studies help me?
Thanks

2 Likes

App is Tab bar app, if I go to another tab and come back, I see the it is updated.

I have done something that no one will approve I believe :D

I added a Bool property, everytime update happens, I toggle that. it works :smile:

I like to know correct way but still not a blocker for me.

I'm seeing the same issue, did you ever figure out what the issue was?

I can see that my State is changing when I insert/remove from the array but the View just doesn't update. Changing tabs, force-quitting, or even adding a bool property to toggle isn't working.

If I initialize the list and hardcode it with an item, it does show up, and I can send an action to remove it and both the State and the View update properly, but if I try adding to it, the State updates but the View doesn't.

Terms of Service

Privacy Policy

Cookie Policy