joebobmiles / zustand-middleware-yjs

Zustand middleware that enables sharing of state between clients via Yjs.
MIT License
103 stars 10 forks source link

zustand-middleware-yjs not working with other zustand middlewares #35

Closed hunterZh37 closed 1 year ago

hunterZh37 commented 2 years ago

Hi, I have been trying to use multiple middleware in a single store (zustand-middleware-yjs being one of them). My implementation looks something like in the picture. Even though the data/state in the syncStore is changed, the zustand data/state living on my other device connecting to the same room("somethingRoom") is not updating.

Screen Shot 2022-05-05 at 9 13 00 AM Screen Shot 2022-05-05 at 9 16 44 AM
joebobmiles commented 2 years ago

This is what I get for advertising compatibility with other middleware without actually testing it first. 😅

Have you tried composing the yjs middleware with only one middleware? For example, what happens when you compose yjs and immer, yjs and computed, or yjs and subscribeWithSelector? If you can test each of those cases, that can help me figure out if this is due to a compatibility issue with one of those middlewares or if yjs is breaking compatibility with all middlewares.

joebobmiles commented 1 year ago

Been a while, and after having returned to this, upgraded the v4 of Zustand, and written tests to try and capture what is happening here, I haven't been able to reproduce this.

If you can give me a reproduction case via CodeSandbox or a Git repository, I can take a deeper look into it. Otherwise, I'll close this issue due to inactivity.

joebobmiles commented 1 year ago

Closing this due to inactivity and inability to replicate the issue.