You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the announcement of SwiftData this week, I'm beginning work on adapting the CoreDataRepository approach to the new framework. This discussion will give anybody interested the opportunity to participate in shaping the new API.
For now, I'm developing the SwiftData API in a separate target of this package. However, the argument could be made for it to live in the CoreDataRepository target (although maybe renamed) or in its own package.
API
UnmanagedModel Equivalent Name
To start, I'm working with a single protocol for the value type called, PersistentModelProxy. This protocol will handle everything the RepositoryManagedModel and UnamangedModel do for CoreData. I hope to get a macro working that can handle the PersistentModelProxy implementation. However, it might turnout that the API will need to bend to match what is best for macro development.
PeristentIdentifier Storage
For CoreData, we have the benefit of the NSManagedObjectID being encoded as an URL on the value type. I'm not seeing a similar feature in SwiftData. There is the possibility of encoding the PersistentIdentifer to Data and storing it in a 'tagged' or 'phantom' type. The down side of that, is cost of encoding and decoding the identifier for each resource on every transaction.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
SwiftData
Overview
With the announcement of SwiftData this week, I'm beginning work on adapting the CoreDataRepository approach to the new framework. This discussion will give anybody interested the opportunity to participate in shaping the new API.
If you're interested to see progress, the working branch for SwiftData is creatively named
swift-data. https://github.com/roanutil/CoreDataRepository/tree/swift-dataPackaging
For now, I'm developing the SwiftData API in a separate target of this package. However, the argument could be made for it to live in the CoreDataRepository target (although maybe renamed) or in its own package.
API
UnmanagedModel Equivalent Name
To start, I'm working with a single protocol for the value type called,
PersistentModelProxy. This protocol will handle everything theRepositoryManagedModelandUnamangedModeldo for CoreData. I hope to get a macro working that can handle thePersistentModelProxyimplementation. However, it might turnout that the API will need to bend to match what is best for macro development.PeristentIdentifier Storage
For CoreData, we have the benefit of the
NSManagedObjectIDbeing encoded as anURLon the value type. I'm not seeing a similar feature in SwiftData. There is the possibility of encoding thePersistentIdentifertoDataand storing it in a 'tagged' or 'phantom' type. The down side of that, is cost of encoding and decoding the identifier for each resource on every transaction.Beta Was this translation helpful? Give feedback.
All reactions