I observed an unexpected result when using YDoc.transact(), hoping someone can shed some light. Here is the minimal repro:
import * as Y from 'yjs'
const yDoc = new Y.Doc()
const yMap = yDoc.getMap()
yDoc.on('update', (update) => {
console.log('update length:', update.length)
})
yDoc.transact((tr) => {
for (let x = 0; x < 1000; x++) {
yMap.set('a', x)
//yMap.set('b', x)
}
})
As written the update observed length is 37, which is around what I’d expect. However, if I un-comment the setter on ‘b’, the update size becomes 17,891.
Is that expected? If yes, how does one use YDoc.transact() such that the changes are collapsed to a reasonable fixed size?