You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my use-case scenario I am sharing arrays among clients, unfortunately on each client I have to keep two copies of the same array: a "local" array created by another framework and your "y-array" used to share it. I can't get rid of the local array because it is not directly accessible, and I need your y-array to ensure consistency among clients.
The framework I am using notifies me with "update", "splice", "splices", etc. events whenever the "local" array changes, and I can change the "local" array by using methods as: "set", "push", "pop", "splice", etc.
Integrating the two implementations was not a problem, but one case is problematic. Whenever the value stored at an index of the "local" array changes and I receive an "update" event from the framework, I have to deal with a very costly operation to notify the y-array.
The "y-array" doesn't define a native "set" method. Right now I am reacting to the "update" event with a combination of ".delete(pos)" and ".insert(pos, [value])", which isn't an optimal solution, because whenever I call these two methods, the Yjs observer fires 2 events, and every single time these methods are fired I have to make many additional checks in order to prevent of entering in a loop.
If y-array had a native "set" method, I would need one single check, which would be significantly better in my use-case scenario.
Is there any reason why the "set(pos, value)" method is not defined in the y-array implementation?
The text was updated successfully, but these errors were encountered:
There was a question like this a year ago (terminology was different then) yjs/yjs#16
The current CRDT approach does not support updating of values. I'm not really aware of any operation based CRDT that does support it. Nevertheless, I think that it is possible to implement this behavior, but it would need some time to realize. I gave it some thoughts, and I plan to support it, but not in the next few months.
We wanted a similar behaviour for an app we are developing, what we did is use a y-array to hold data that won't change and a y-map for metadata associated to the items in the array.
Hello!
I will briefly explain my problem:
In my use-case scenario I am sharing arrays among clients, unfortunately on each client I have to keep two copies of the same array: a "local" array created by another framework and your "y-array" used to share it. I can't get rid of the local array because it is not directly accessible, and I need your y-array to ensure consistency among clients.
The framework I am using notifies me with "update", "splice", "splices", etc. events whenever the "local" array changes, and I can change the "local" array by using methods as: "set", "push", "pop", "splice", etc.
Integrating the two implementations was not a problem, but one case is problematic. Whenever the value stored at an index of the "local" array changes and I receive an "update" event from the framework, I have to deal with a very costly operation to notify the y-array.
The "y-array" doesn't define a native "set" method. Right now I am reacting to the "update" event with a combination of ".delete(pos)" and ".insert(pos, [value])", which isn't an optimal solution, because whenever I call these two methods, the Yjs observer fires 2 events, and every single time these methods are fired I have to make many additional checks in order to prevent of entering in a loop.
If y-array had a native "set" method, I would need one single check, which would be significantly better in my use-case scenario.
Is there any reason why the "set(pos, value)" method is not defined in the y-array implementation?
The text was updated successfully, but these errors were encountered: