6 ms·
Noob here, how does SwiftData compare to Redux (as a paradigm)?
by tifa2up 3y ago
Noob here, how does SwiftData compare to Redux (as a paradigm)?
- jahewson 3y agoLooks pretty different. Much closer to more modern state management approaches such as Recoil and Jotai.
- _trackno5 3y agoI don't get what you're saying here. Swift Data is just a framework to annotate data structures to be stored by Core Data. It looks a lot like an ORM.
- jahewson 3y agoIf we think of CoreData's role here as simply providing persistent storage then the annotation layer is the interesting bit - binding a persisted model to a view via a query is conceptually similar to Recoil's atoms' support for complex fetching, persistence, and offline support.
- bigtechennui 3y agoThinking of CoreData as simply providing the persistence layer is incorrect. It also provides the schema. CoreData’s object graph management and persistence are separate - you can use CoreData without persistence, but you can’t use it without a schema. The annotations are for defining the CoreData schema – i.e. the necessary piece – rather than relying on a schema definition file as one would prior to SwiftData. There are additional syntactic niceties for SwiftUI binding, but the annotations are very much an ORM.
- esprehn 3y agoWhat part makes you think of Recoil? CoreData (and now SwiftData over it) are more like ActiveRecord in my experience.
- jahewson 3y agoYes, that's CoreData but we're talking about this new intermediate SwiftData layer. If you think of the ORM part as just "storage" the bindings are quite Recoil-like. Take a look at `recoil-sync`, which handles querying and syncing with persistent storage.
- RandallBrown 3y agoIt's not really comparable. SwiftData is the Swift version of Apple's CoreData, which is pretty much a database ORM. It's a massive improvement on the old APIs that were written decades ago for Obj-C.
- manmal 3y agoIf you need Redux in SwiftUI, you should check out ComposableArchitecture.