YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.

Home Page:https://syncedstore.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

only getting proxy object when trying to access store

michaelpalumbo opened this issue · comments

Hi thanks for making SyncedStore!

I'm unable to access any nested properties in my store, instead all that I get is a Proxy Object.

When I do the following:

let op = { asdf34: { _props: { kind: 'math', pos: [ 0., 0., 1.] } }, id: 'asdf34' }
let document = syncedStore({ patch: {} });
// later on in the script I update the store
document.patch[op.id] = op

// when I want to print or access any of the properties of my store, all I get is a Proxy Object
console.log(document.patch['asdf34']) // prints: Proxy(Object){}
// if I try to access a nested prop, it returns undefined
console.log(document.patch[asdf34']._props.kind) // prints: undefined
// however, I can at least verify that the ID exists as a property of .patch
console.log(Object.keys(document.patch)) // prints: [ 'asdf34' ] 

What am I doing wrong here?

commented

console.log(document.patch[asdf34']._props.kind) // prints: undefined

This is expected to return undefined, because you the way you assign your object the value should be under document.patch['asdf34']['asdf34']._props.kind I think

The proxy object is expected, but you should be able to use JSON.stringify to inspect the contents