zustand-middleware-yjs
zustand-middleware-yjs copied to clipboard
Fix Compatibility with Immer Middleware
See #53.
Immer invokes Object.freeze on non-primitive values such as arrays and objects. This is how it achieves immutability. This presents two problems for the Yjs middleware:
- Client updates must obey Immer's rules for modifying objects and arrays (annoying but doable).
- State updates triggered on the client by a peer need to either:
a. Invoke Immer's
producefunction (unfavorable coupling), or b. Detect if the object to modify is frozen or otherwise inextensible and treat it as immutable.