Yjs is working sooo well for syncing 9+ sessions of code within a single YDoc = this is amazing!
Now I’m trying to store and display that list of 9+ sessions as a Y.Array for keeping track of its ID
and NAME
. I have more experience with array’s, so I figured that I would just store an array of objects, ie: {id:1, name:'Session 1'}
. This worked fine, until trying to allow users to rename their session and was surprised that Y.Array had no (edit, just found my BUG! aargh… this technique is now working… though question still remains)set()
function to overwrite data? So instead I’ve tried deleting that index and replacing it – then having all clients refresh the list of available sessions (pulldown select). Just noticed that it wasn’t always deleting itself from the array causing an issue (surely my own codes bug).
Just wanted to ask if there’s a reason that Y.Array data doesn’t have a function to change the value of an index (or it does and I didn’t see it)? I noticed that Y.Map has a get()
and set()
– and I can cycle through it just like an array = guess I should be using that (and read more about map’s since Yjs uses it a lot…)
TLDR; – When is it better to use Y.Array versus Y.Map, and can Y.Array also overwrite data or best to use Y.Map for that?