jorendorff / peeredit

A toy collaborative text editor to illustrate CRDTs.
24 stars 1 forks source link

Pause syncing between RGA and editor? #2

Open ffd8 opened 5 years ago

ffd8 commented 5 years ago

First off this is an amazing lib! True to your textarea-distributed talk it syncs sooo much better than every other systems I tried.

Unfortunately it's syncing too well.... How could I go about pausing the syncing? I'd like it to keep it's preferences to the socket and editor, etc... just temporarily mute any communication between the editor and the RGA – Hmm perhaps just unbinding the two temporarily... then reconnecting and having the RGA's history replace the contents of the editor.

Why? I'm implementing this for a collaborative coding/visuals tool and want the user to have the option to swap between collaborative-mode and detour-viewing sketches from their local list (loading sketchs simply replaces the editor's value). Maybe there's a feature in there with the tie/untie that I can use to accomplish this?

jorendorff commented 5 years ago

Hi, I'm really sorry I didn't see this. I just haven't been working in github much lately.

I think it's awesome you're trying this out. Probably the easiest way to do what you're asking about is to call .destroy() on the AceEditorRGA, then create a new one, and possibly a whole new ACE editor, later.

ffd8 commented 5 years ago

No problem + thanks for the suggestion, though I haven't had success yet destroying and reactivating for group of users viewing a shared doc.

Now I'm wondering if there is something similar but different... if one wants to replace the entire ace editor contents (maybe loading new contents for all to see and work with) this causes a huge lag/crash on each user as each op update is likely accounted for and reproduced (might also cause crazy pingpong as update enters one persons code and their editor sends back a change to the group?) – related to this pause question.. is there a successful way to replace all of the contents while simultaneously reseting the RGA history? Workflow is as such:

Hope that's making sense– somehow working around the op step by step updates. I'm guessing this has something to do with that welcome socket message where the history is shared...

ffd8 commented 4 years ago

Sorry, but wanted to bump this again with the specific question, is it possible to replace/restart the history of an RGA instance?

Essentially RGA would be paused, entire code of editor would be replaced via socket emit to all users, history would restart/reset with that current shared state, and history would resume. Sound possible?