Be careful with large data sets (memory). In this example you can see why I use Active Record, I can use Movie.movies factory method in many situations.
Yes with static data, Active Record can be nice. With large dataset, we needs to be careful on the "Single Source of Truth" (memory, data sync, .)
Also from my experience ObservableObject to ObservableObject communication / observation is not good
Agree, I also avoid nested observables. Often it can be resolved with smaller views+logic / container view.
Apple use ECS for GameplayKit. It’s great for Games but don’t see it in Apps today (
Yes we used it for a game (not GameKit). And on a second project it was for everything (Gameplay + UI + Services).
When you say View = f(State), it is the same thing with ECS. We have something close with the existing SwiftUI but maybe more later with an official framework or else.
With the sheet modifier it is what we had a lot for UI: set a flag, the view controller listen and show the popup.
Global context, Gameplay context, UI context, services context, you can split as needed by the app.
Global -> static data, configuration etc
Gameplay -> player position, events, game state
UI -> UI state, rewards available, current tab, intent to show with priority
services -> initialize and handle the logic for services, analytics, socials, persistence, sync etc.
Of course, the ECS performance gain is overkill for a UI based app but the data logic and system execution (≠ OOP) is extremely easy to use, maintainable, and evolvable.
Subject for another thread!
Thank you for your detailed posts / examples.