tree mirror; possible to bidirectionally share changes?

244 views
Skip to first unread message

Mike Reinstein

unread,
Oct 28, 2012, 6:53:55 AM10/28/12
to mutation-sum...@googlegroups.com
hey Rafael,

this library is _amazing_. Thanks for creating it! I have a question about mutation summary, and the tree mirror example. I'm wondering if you could provide some insight into what would be involved in making it so 2 or more viewers could share edits to a DOM. Said differently, in the example, one is  reader and the other is writer. I want to make a version where both can read and write. I'm assuming tight constraints (no js state DOM elements only, and a central server between them is ok)

Any thoughts would be greatly appreciated. 

thanks again!

Rafael Weinstein

unread,
Oct 28, 2012, 7:00:54 AM10/28/12
to mutation-sum...@googlegroups.com
Hi Mike,

I'm glad you find it useful.

I'm not sure I fully understand the use case yet. Perhaps you can
describe it in more detail?
> --
> You received this message because you are subscribed to the Google Groups
> "mutation-summary-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mutation-summary-discuss/-/WgPwrvplAWUJ.
> To post to this group, send email to
> mutation-sum...@googlegroups.com.
> To unsubscribe from this group, send email to
> mutation-summary-d...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mutation-summary-discuss?hl=en.

Mike Reinstein

unread,
Oct 28, 2012, 7:11:43 AM10/28/12
to mutation-sum...@googlegroups.com
Hi Rafael,

My use case is multi-user live html doc collaboration. The treemirror example provides an elegant way to represent and apply DOM changes almost like patches. That's half the battle. Well, technically it's less than half; there are a number of non-trival synchronization issues that would need to be solved if multiple people are editing a shared document. :) But that being said, baby steps. My goal is to evaluate the ability for people to edit 2 copies of the same doc and see if they could share changes with each other using mutation-summary and maybe a hacked up version of the treemirror with a little socket.io and nodejs thrown in there for good measure.
> mutation-summary-discuss+unsub...@googlegroups.com.

Rafael Weinstein

unread,
Oct 28, 2012, 8:02:10 AM10/28/12
to mutation-sum...@googlegroups.com
I see. So, yes you are correct: there are some synchronization issues
you'll need to solve, but here's one approach I can imagine:

-Two versions of the same document loaded into two separate browsers.
-Each document has a MutationSummary observing it and using TreeMirror
to serialize changes which originate from user input to the other
side.

So the key thing you'll want to avoid is having changes which come in
from the remote editor detected by the local MutationSummary and sent
back to it. Thankfully, there's an easy way to do that:
disconnect()/reconnect(). Basically in each side, when you receive
remote changes, perform a disconnect() on the local MutationSummary
while you apply the changes, then reconnect() when the changes are
complete.

Be aware that disconnect() returns a collection of summaries
representing any changes which have occurred since the last callback
and the time you call disconnect(). In most instances this should be
empty (and return undefined). Just be aware -- and maybe log an error
if you there are any changes at that point so you can try to figure
out why.

It's been a while since I looked at the TreeMirror code, so I can
imagine you may need to modify it to do this correctly. Hopefully, the
code is readable enough that doing this won't be too hard.

Good luck!
>> > mutation-summary-d...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/mutation-summary-discuss?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "mutation-summary-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mutation-summary-discuss/-/kcZdSlxhyqIJ.
>
> To post to this group, send email to
> mutation-sum...@googlegroups.com.
> To unsubscribe from this group, send email to
> mutation-summary-d...@googlegroups.com.

mkl...@gmx.net

unread,
Jun 17, 2014, 1:47:22 PM6/17/14
to mutation-sum...@googlegroups.com
Hey everyone,

I'm currently implementing https://github.com/marcelklehr/dom-ot -- an OT type (operational transformation) for the DOM that will be able to take Mutation summaries as input to
construct transformable operations, that can be sent over the wire to apply them on the other end. Together with an ot managing library like shareJS or gulf (my personal OT managing flavour; see https://github.com/marcelklehr/gulf), this should allow multiple users to collaborate on the same DOM fragment.

Rafael Weinstein

unread,
Jun 24, 2014, 1:15:28 PM6/24/14
to mutation-sum...@googlegroups.com
Hi Mike,

It's a very interesting problem -- and definitely more complex. I imagine you've already thought about some of the challenges. I haven't tried it, so I don't know the answer. My guess is that there is no *right* answer and many different approaches. The preferred approach probably has to do with your specific use case.

The only real suggestion I have is to look for simplifying assumptions (for instance, optimistically assume that only one side or the other will make changes at once, and then figure out how to detect & handle when that assumption falls down).

Good luck. If you have something to show when it's working, I'm sure I'm not the only one who would be interested to see it.


--
You received this message because you are subscribed to the Google Groups "mutation-summary-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mutation-summary-d...@googlegroups.com.

To post to this group, send email to mutation-sum...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages