Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Counter and AutomergeText so that they only register change signals IF the content they point to changes #152

Closed
heckj opened this issue Apr 29, 2024 · 0 comments · Fixed by #154
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@heckj
Copy link
Collaborator

heckj commented Apr 29, 2024

With #150, AutomergeText and Counter (as ObservableObjects) reflect a signal that "something's changed" when ANY change happens to a document. Perhaps with #148 in place, update that process (and assocaited tests) so that the their "objectWillChange" signals are only triggered when the content they point to has changed.

The easiest cut would be to add additional tracking in AutomergeText to hold a "current value hash" and compare when the Doc.objectWillChange() comes in, potentially reflecting updated content in the Automerge document.

A more optimal solution would be to leverage the diff API (#148) and have the instances watch for only changes of their objId, which would potentially mean a different Combine published exposed that provides more granular data than objectWillChange(), ideally with information about what changes parsed from the patches returned by the diff API.

There's variations on this that might include instances of AutomergeText and Counter registering a callback function that a Document could be responsible for triggering, which would move the logic for this filtering and triggering from AutomergeText and Counter into Document itself, which could be notably more efficient in the scenario of lots of these instances, a deep document, and sparse change updates via merge, sync, etc.

@heckj heckj added enhancement New feature or request help wanted Extra attention is needed labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant