automerge / automerge-swift

Swift language bindings presenting Automerge

Home Page:https://automerge.org/automerge-swift/documentation/automerge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add doc.objectDidChange?

jessegrosjean opened this issue · comments

In addition to objectWillChange I often feel myself wanting an objectDidChange event. I know SwiftUI doesn't need it, but generally didChange events seems like the useful default. Does it make sense to add this event to doc. And also fire it outside the sync block so that document state can be read immediately when receiving the event?

There's nothing in the framework integration that use anything like this (ObservableObject is explicitly only a change signal, and 'objectWillChange), so if we were going to add our own "objectDidChange" equivalent kind of thing, I'd be very tempted to do something to include information about _what_ changed - the whole set of data from heads()` comes to mind. I haven't thought anything out on this front though, and don't have my own specific use case for what this is enabling.

so if we were going to add our own "objectDidChange" equivalent kind of thing, I'd be very tempted to do something to include information about what changed

That would be preferable to me, just more work. I guess it should include pre change and post change heads? Then later when #148 is available the listener will be able to generate the specific Patches for the change. That would be useful in many scenarios where the goal is to observer an Automerge.Document and process all changes.