I switched from using @Query to @ModelActor because of the following reasons:
Performance Issues: With @Query, my app became unresponsive with large datasets because data fetching occurred on the main thread.
Integration with CKSyncEngine: I needed to implement @ModelActor anyway to allow CKSyncEngine to add data to local persistent storage from the background.
In my current setup, the onAppear() method for my view calls the getItems() function on my model actor, which returns [ItemsDTO] and then View renders them.
However, I'm now facing a challenge in achieving the same automatic data refreshing and view updates that @Query provided. Here are a few potential solutions I'm considering:
Periodic Data Fetching: Fetch data at regular intervals to keep the view updated. But this seems expensive.
Local Write Monitoring: Monitor all local writes to automatically trigger updates when changes occur. But this is quite a lot of code I would have to write myself.
Switch to manual refresh: Users would have to manually trigger UI updates by pressing button.
Reintroduce @Query: Writes would happen from ModelActor, but reads would still happen from Main thread. But then again app would become unresponsive on reads.
If you have any additional ideas or best practices for maintaining reactivity with @ModelActor, I'd love to hear them!