Changing a value of an element in YArray

I know that this has been discussed ‘Update values in y-array (list structures)’ and ‘Set method’, however the discussion has been closed 3 years ago with no updates. I was wondering if there is a smarter/more efficient way of changing value of an element of YArray than this:

const ydoc = new Y.Doc();

ydoc.getArray('array').push(0); // [0]

// set the value of index 0 to 1 
ydoc.transact(() => {
      ydoc.getArray('array').delete(0); // []
      ydoc.getArray('array').insert(0, [1]); // [1]
});

Nope, the same recommendations still apply…

Thanks for looking up the old threads.

Something you could do is having Y.Maps inside of the Y.Array. You can change the values of a Y.Map - i.e. ydoc.getArray().get(i).set('value', [1]). The approach that you described uses less space, but it is prone to duplication (two users replacing the same value will both insert, but it will only result in one deletion).