YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.
https://syncedstore.org
MIT License
1.75k stars 54 forks source link

Supporting array assignment #112

Closed pierscowburn closed 1 year ago

pierscowburn commented 1 year ago

Thanks again for a great library – it continues to be super useful in our application!

I noticed that there's a reference in the code to array assignment not being supported, and have run across this when trying to use array assignment on an upcoming feature. I was wondering if you had an idea as to how much work is required in order to support this – i.e. are there gotchas you're aware of that lead to the decision not to support it yet?

needs commented 1 year ago

Here is how to set an array value at some specific index when using synced store and Yjs:

myArray.splice(index, 1, newValue);
YousefED commented 1 year ago

The reason array assignment is not supported is explained here: https://github.com/YousefED/SyncedStore/issues/59

You could indeed use splice as a workaround