Yjs Redux binding

I’m planning to write an adapter that uses Yjs to synchronize a Redux Slice. In this way the application logic doesn’t have to be aware of Yjs being involved.

Ideally, I would like to build this in a generic way, so that the adapter can be used for new slices without much modification.

Before taking this too far I first want to check with the community to see if something like this already exists or if someone already tried something similar. I’d love to hear your input.

2 Likes

Ended up going with a solution similar to https://github.com/joebobmiles/zustand-middleware-yjs such that:

  • Yjs → Redux in one operation (acceptable since we use memoized selectors (through reselect, through Redux Toolkit))
  • Redux → Yjs through patchSharedType that does clever diffing

I had a similar idea recently but it seems like you got much farther than I did. I desperately need exactly what you are describing. Could you possibly make it public? I know others would find it useful too.

I’d love to open source it but we are still shaping some things up. I’ll let you know when it’s done, I think we can have something by next week. Still blocked by some other things that need finishing up. This is part of my work at Sana Labs.

The core ideas is captured by my previous post. There is nothing too fancy going. We still need to figure out if we want patchSharedState to handle Y.Text or just string and how to best perform update actions in Redux (that of course sync seamlessly with Yjs) - our current approach is a bit bulky but we have an idea for how to improve it.

That’s great to hear. Can’t wait to take a look!