yjs / y-indexeddb

IndexedDB database adapter for Yjs
https://docs.yjs.dev/ecosystem/database-provider/y-indexeddb
Other
210 stars 31 forks source link

observe does not work for Y.Map of Y.Arrays #41

Closed eberberich closed 1 month ago

eberberich commented 2 months ago

Checklist

Describe the bug

The observe callback for (a) nested Y.Array(s) in a Y.Map is not executed when indexeddb persistence is in place.

To Reproduce

Run the attached minimal example persistence-problem.zip

Search in index.js for PROBLEM 1/2/3 to find the code places

Expected behavior

The observe callbacks for the nested arrays work, and the nested arrays do not start from scratch upon page reloads!

Environment Information

eberberich commented 2 months ago

Here is a video

https://github.com/user-attachments/assets/c2668655-e1d8-422e-8b73-6334d0fac544

eberberich commented 2 months ago

Any ideas here?

dmonad commented 1 month ago

I looked through the source code of your app (which I normally don't do), and it seems that you are overwriting the data on every load. You register event listeners on Y.Arrays that you overwrite when you enable persistence.