-
Notifications
You must be signed in to change notification settings - Fork 15
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
Expose heads raw state representation #191
Conversation
3167492
to
5fa3988
Compare
c588e47
to
84896a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the relevant methods are kind of hidden on Set<ChangeHash>
and Data
, I think it's worth adding something to the overall documentation for ChangeHash, or potentially Document.heads()
to reference them - otherwise they'll be really hard to find for anyone searching for this functionality. Not critical for this PR though.
Co-authored-by: Joseph Heck <heckj@mac.com>
One thing that might be worth thinking about. In the |
Created #193 to extend this to expose, and use, the tryFrom logic in the Rust core library within the internal initializer for ChangeHash |
Motivation
Sometimes we want to persist in our domain a state representation based on
Set<ChangeHash>
(aka heads) without coupling to the Automerge library. In this way, we can restore this state by moving back to the Automerge domain. It is usually quite interesting to implement an undo manager based on "commits".Introducing a
raw()
method to retrieve the raw representation ofheads
without any Automerge dependency; and also the go-back action intoSet<ChangeHash>
.side-note: as we use an opaque type to encode the raw version of a group of change hashes, I am just checking it contains packages of 32 bytes to retrieve the associated change hash - after retrieving it, in case of not valid ChangeHash document will throw exceptions.