Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxies created before a YDoc update, do not update #132

Open
tobowers opened this issue Dec 8, 2024 · 0 comments
Open

proxies created before a YDoc update, do not update #132

tobowers opened this issue Dec 8, 2024 · 0 comments

Comments

@tobowers
Copy link

tobowers commented Dec 8, 2024

I came across this in our syncing, but minimized it down to the below example. The behavior I'm seeing is that if you save a proxy to a variable, that proxy will not update when the document updates.

  it.only('updates a saved proxy', async () => {
    const doc = new Y.Doc()
    const shape = {
      data: {} as Record<string, any>
    }

    const store = syncedStore(shape, doc)

    store.data.someObj = {}
    store.data.someObj.hello = 'world'

    const originalObj = store.data.someObj

    const mp = new Y.Map()
    mp.set('hello', 'world')
    doc.getMap('data').set('someObj',  mp)

    // this passes
    expect(store.data.someObj).toEqual({ hello: 'world' })
    // this fails
    expect(originalObj.hello).toEqual('world')
  })
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant