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

Yjs Electric provider example #1508

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Yjs Electric provider example #1508

wants to merge 28 commits into from

Conversation

balegas
Copy link
Contributor

@balegas balegas commented Aug 10, 2024

This an example of a y-provider based on Electric.

The code is based on y-webscocket and the yjs-demos/codemirror.next

  • Awareness and broadcast across tabs
  • IDB persistence
  • Resume shape from last offset
  • Broadcast changes between tabs
  • Electric theme was replaced with bare minimum style (happy to revert)
  • Experimental compaction of YDoc

Copy link
Contributor

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

examples/nextjs-yjs-codemirror/README.md Outdated Show resolved Hide resolved
examples/nextjs-yjs-codemirror/app/y-electric.js Outdated Show resolved Hide resolved

This comment was marked as outdated.

This comment was marked as outdated.

@balegas balegas force-pushed the balegas/yjs-electric branch 7 times, most recently from 6164404 to 1faec98 Compare August 15, 2024 00:51
@balegas balegas changed the title WIP: Yjs-Electric Codemirror demo WIP: Yjs-Electric provider example Aug 15, 2024
@balegas balegas changed the title WIP: Yjs-Electric provider example Yjs Electric provider example Aug 15, 2024
@balegas balegas requested a review from samwillis August 20, 2024 08:25
@balegas balegas self-assigned this Aug 20, 2024
@balegas balegas marked this pull request as ready for review August 20, 2024 08:26
@balegas
Copy link
Contributor Author

balegas commented Aug 20, 2024

Experimental compaction of YDoc
I've implemented compaction on the server by creating a new Ydoc, truncating the table and storing the new Ydoc. The truncation causes a shape rotation that will essentially clear the shape and start fresh from the Ydoc checkpoint.

This obviously isn't a complete implementation as the TRUNCATE also deletes all other Ydocs that we might be storing :D. The idea was to demonstrate the use of shape rotation to clear the log of operations. We should think if we want to expose the delete shape endpoint on the backend or not. The proxy could disallow any requests coming from the user.

EDIT: reflecting a bit more, maybe the best is to leave this out because we'll be able to do compaction a lot better in the future.

@balegas balegas force-pushed the balegas/yjs-electric branch 2 times, most recently from 7f083e3 to 567c81d Compare August 23, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants