I abused JS to abuse Yjs
Because I just wanted to keep my TypeScript classes. I was not trying to build a CRDT framework. Honestly, I really, really wanted to avoid building one, and I guess you can see that in the API. I ended up creating Plexus ( https://plexus.here.build/ , https://github.com/here-build/plexus ). I had a fairly large TypeScript object model. It originally grew out of the open-source model by third…
The author wanted to keep their TypeScript classes and didn't want to build a CRDT framework. They created Plexus, a framework that allows them to use their existing classes and MobX decorators while collaborating collaboratively with Yjs. The problem was that Yjs is a CRDT engine, which gives shared data structures that can be modified independently on different peers and merged, but using them directly would make the application model incompatible with their existing classes.
To solve this, the author needed to change the decorator used, not the model. However, the migration was challenging because the application model was already built around classes and MobX decorators. The author tried to use stage-3 decorators to avoid the temptation of using stage-2, but it required polymorphic decorators to replace getters and setters on auto-accessors.
This made the process more complex, but it allowed them to keep their existing classes and only change the decorator used, keeping the external behavior of their classes.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.