zustand-middleware-yjs icon indicating copy to clipboard operation
zustand-middleware-yjs copied to clipboard

Fix Compatibility with Immer Middleware

Open joebobmiles opened this issue 2 years ago • 0 comments

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:

  1. Client updates must obey Immer's rules for modifying objects and arrays (annoying but doable).
  2. State updates triggered on the client by a peer need to either: a. Invoke Immer's produce function (unfavorable coupling), or b. Detect if the object to modify is frozen or otherwise inextensible and treat it as immutable.

joebobmiles avatar Jul 03 '23 15:07 joebobmiles