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

Liveblocks storage cannot be assigned to Vue ref (reactive variable) #66

Closed
captaindev404 opened this issue Feb 11, 2022 · 1 comment
Closed
Labels
enhancement New feature or request feature request Feature requested by the community packages

Comments

@captaindev404
Copy link
Contributor

@ctnicholas

Hi, this is more of a "let you know" than a "this needs fixing" message—someone else may come across this.

If you try to assign Liveblocks storage to a Vue ref (reactive variable) it won't work:

const { root } = await room.getStorage()
root.set('list', new LiveList())

const list = ref()
list.value = root.get('list')

// ERROR: Cannot read private member from an object whose class did not declare it
list.value.push(1)

It works fine if you use a function to return the storage instead:

const { root } = await room.getStorage()
root.set('list', new LiveList())

const list = ref()
list.value = () => root.get('list')

// Works fine
list.value().push(1)`

I've written exactly why this doesn't work in a CodeSandbox example:
https://codesandbox.io/s/liveblocks-proxy-storage-fix-eitb1?file=/src/index.js

I don't know if this is a problem that needs fixing, but it might be something to be aware of!
Discord: https://discord.com/channels/913109211746009108/913158542565994606/941328794130722868

@captaindev404 captaindev404 added enhancement New feature or request feature request Feature requested by the community labels Feb 11, 2022
@GuillaumeSalles
Copy link
Contributor

Closing in favor of #631

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request Feature requested by the community packages
Projects
None yet
Development

No branches or pull requests

2 participants