Post

Replies

Boosts

Views

Activity

Replacing array in Observed object won't update UI.
Hello, following is the issue: I have a @Observable view model which has an array of @Observable Items. Tapping an item leads to a detail like view to submit a value to the item. This work thru bindings. However I have the need to replace the contents of the array entirely with a fresh version loaded from the network. It will contain the "same" objects with the same id but some values might have changed. So replacing the entire array seems to not update the UI because the IDs are the same as before. Also this seems to break the bindings because when replacing the array, editing no longer updates the UI. How to test the behavior: Launch the app in simulator. Add some values to the items by tapping on an item and then on add. Notice how changes are updated. Tap the blue button to sync fresh data to the array. (Not replacing the actual array) Confirm everything is still working Replace the array with the red button. Editing and UI updates are broken from now on. What is the proper way to handle this scenario? Project: https://github.com/ChristianSchuster/DTS_DataReplaceExample.git
2
0
215
2w