Forked
I’m launching a new Swift framework called Forked for working with shared data, both on a single device, and across many.
[…]
The merging that
@ForkedModel
provides is pretty powerful. It does property-wise merging of structs, and if you attach the@Merged
attribute, you can add your own custom merging logic, or use the advanced algorithms built in (like CRDTs).To give an example, the
notes
property above is aString
. With@Merged
applied, it gets a hidden power — it can resolve conflicts in a more natural way. Rather than discarding one set of changes, or merging to give somewhat arbitrary results, it produces a result a person would likely expect. For example, if we begin with the text “pretty cool”, and change the text to “Pretty Cool” on one device, and to “pretty cool!!!” on another, the merged result result will be “Pretty Cool!!!”. Nuff said.And this works within your app’s process, between processes (eg with sharing extensions), and even between devices via iCloud.
See also:
- CRDTs are the future (via Hacker News)
- 5000x faster CRDTs (via Hacker News)
- Making CRDTs Byzantine Fault Tolerant (via Hacker News)
Previously:
- A First Replicating Type
- Syncing Core Data With CloudKit and NSPersistentCloudKitContainer
- Core Data Ensembles