automerge/automerge-swift
关于
提供 Automerge 的 Swift 语言绑定
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Automerge-swift
The project is an Automerge implementation, a library of data structures for building collaboraative applications, in Swift. Automerge is cross platform and cross-language, allowing you to provide collaboration support between browsers and native apps.
The API Documentation provides an overview of this library and how to use it.
Automerge Repo (Swift) is a supplemental library that extends this library. It adds pluggable network and storage support for Apple platforms for a more "batteries included" result, and is tested with the JavaScript version of Automerge Repo.
The open-source iOS and macOS document-based SwiftUI App MeetingNotes provides a show-case for how to use Automerge to build a live, collaborative experience. MeetingNotes builds over both this library and the repository to provide both WebSocket and peer to peer based networking in the app.
Quickstart
Add a dependency in Package.swift, as the following example shows:
let package = Package(
...
dependencies: [
...
.package(url: "https://github.com/automerge/automerge-swift.git", from: "0.5.2")
],
targets: [
.executableTarget(
...
dependencies: [.product(name: "Automerge", package: "automerge-swift")],
...
)
]
)
Now you can create a document and do all sorts of Automerge things with it
let doc = Document()
let list = try! doc.putObject(obj: ObjId.ROOT, key: "colours", ty: .List)
try! doc.insert(obj: list, index: 0, value: .String("blue"))
try! doc.insert(obj: list, index: 1, value: .String("red"))
let doc2 = doc.fork()
try! doc2.insert(obj: list, index: 0, value: .String("green"))
try! doc.delete(obj: list, index: 0)
try! doc.merge(other: doc2) // `doc` now contains {"colours": ["green", "red"]}
For more details on the API, see the Automerge-swift API documentation and the articles within.
Note: There was an earlier project that provided Swift language bindings for Automerge. The repository was renamed and archived, but is available if you are looking for it.
探索相关项目
加载中…