Comments (4)
Even with the naming of objectWillChange, I've never been terribly clear on what the timing requirements are far, and how those process in terms of the current runloop through synchronous calls.
Agreed. I don't really know either, and it's always been a weird looking call.
Right now it's the only way to subscribe for changes in Automerge, I think maybe that's the biggest problem. Really need a real event, instead of trying to bend this one to do what I want.
With that said I still think the current setup where you get an exception when trying to access the document (unless you debounce) doesn't seem right to me and I would think is sure to generate errors for others.
I don't immediately see anywhere that you are checking to see if there will be a change before calling objectWillChange
. I guess my vote would be to move it outside of the sync block and see if MeetingNotes still behaves.
from automerge-swift.
Even with the naming of objectWillChange
, I've never been terribly clear on what the timing requirements are far, and how those process in terms of the current runloop through synchronous calls. I've no qualms with generally calling this outside (prior) to the dispatchqueue sync
protection lock, although I think I recall in some places I'm actually checking to see if there's any change to be made, and skipping calls to change if contents are identical, that might stymie some of this. But i'm saying that without coffee yet this morning and no code in front of me. ;-)
from automerge-swift.
Ah - found what I was thinking about - there's calls in Counter & AutomergeText objects (reference type overlays that dynamically read/write into Document as changes are made to them) that also expose ObservableObject, and it's in there that I'm doing the "post-change" checking - the vague-ish-workaround being that I wanted to know if any given 'objectWillChange' was the a relevant result for the part of the schema that the object tracks. The change signals from a document coming from any of: user interactions, calls to merge other docs, applying sync messages, or even encoded changes locally.
In those cases the "objectDidChange" is far more of how I coded it up - with the sole purpose behind those being "do I need to send a signal to UI frameworks to re-render the content", and not at all the "can I capture the state markers of the document" kind of thing. Anyway, shouldn't be an issue to muck with the Document calls directly and move them outside of the DispatchQueue.sync
from automerge-swift.
@jessegrosjean Take a look over #179 - I've added a test that mostly is verifying that the specific thing we're after (capturing heads prior to a change) is, in fact, possible (test crashed prior to the code changes, as expected with attempting synchronous access to Document
).
from automerge-swift.
Related Issues (20)
- Accessing history timestamp HOT 4
- Add Observable to Automerge.Document
- Revise documentation to better describe API layers HOT 5
- Create a parallel Document that's actor protected, with async methods for updating content HOT 2
- Encoding an empty dictionary throws an error HOT 2
- Timestamp HOT 5
- AutomergeText.textBinding() instances not bound to a document don't publish updates HOT 7
- expose the diff set of APIs
- AutomergeText doesn't have any change notification triggered on doc updates HOT 1
- update Counter, and refactor schema creation logic
- update Counter and AutomergeText so that they only register change signals IF the content they point to changes
- expose Blocks API to Swift HOT 2
- Sendable conformance warnings
- Overzealous observability change notifications
- Add doc.objectDidChange? HOT 2
- Race in common usage of Document.save, document.encodeChangesSince, and Document.heads? HOT 1
- expose Automerge::Diff to Swift
- exposing Automerge::get_marks through to Swift
- extend ChangeHash internal initializer to use Automerge core logic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from automerge-swift.