electric icon indicating copy to clipboard operation
electric copied to clipboard

Yjs Electric provider example

Open balegas opened this issue 1 year ago • 3 comments

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

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

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

balegas avatar Aug 10 '24 00:08 balegas

Deploy Preview for electric-next ready!

Name Link
Latest commit 551382bd6015acecc1b01211524f8fa6f56f75e2
Latest deploy log https://app.netlify.com/sites/electric-next/deploys/66bb8f6879b9280008498879
Deploy Preview https://deploy-preview-1508--electric-next.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Aug 13 '24 16:08 netlify[bot]

Deploy Preview for electric-next ready!

Name Link
Latest commit 88b49207d665565fd79117ea36afb1b93411f38b
Latest deploy log https://app.netlify.com/sites/electric-next/deploys/6756ec62ef7a4500089e7a32
Deploy Preview https://deploy-preview-1508--electric-next.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Aug 13 '24 17:08 netlify[bot]

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 avatar Aug 20 '24 08:08 balegas