automerge / automerge-swift

Swift language bindings presenting Automerge
https://automerge.org/automerge-swift/documentation/automerge/
MIT License
233 stars 13 forks source link

Create a parallel Document that's actor protected, with async methods for updating content #120

Open heckj opened 7 months ago

heckj commented 7 months ago

The idea being ultimately replacing the DispatchQueue protection, and shifting to fully embracing swift's async/await structure. With Swift 6 (fully embracing this safety marker) coming this June (2024), we'll want to make sure at a minimum we pass all Sendable checking.

In addition, the more recent updates to UniFFI (2.6.1) have started to embrace coordinating async calls between Rust and Swift. We're not taking advantage of these yet, but it may prove useful down the road.

Since I think we'll want to maintain backward compatibility for a while, a parallel type to Document would make a lot of sense, and we can slowly shift/deprecate the current version as the experiments vet themselves out in practical (app) use.

lightsprint09 commented 6 months ago

I guess by using an internal DispatchQueue and conforming to Sendable (maybe unsafe) your are already ready for Swift 6. Not sure if it is worth rewriting everything using actors

heckj commented 6 months ago

@lightsprint09 You're correct - I've verified Automerge-swift is completely good for Swift6 mode already, but in learning more about it, it seems like it may be a good way to also accomplish it, so I wanted to try it out