We have this code to go from a non-gc’d document to a gc’d one:
const neverCollectedYDoc = new Y.Doc({ gc: false });
Y.applyUpdate(neverCollectedYDoc, initialState); // From Data Stores
Y.applyUpdate(neverCollectedYDoc, streamData); // From Memory Streams
const snapshot1 = Y.snapshot(neverCollectedYDoc); // Our Snapshot
const neverGarbageCollectedState = Y.encodeStateAsUpdate(neverCollectedYDoc); // Our history doc
// This action converts it to a garbaged collected state
const collectedDoc = new Y.Doc({ gc: true });
Y.applyUpdate(collectedDoc, neverGarbageCollectedState);
const collectedState = Y.encodeStateAsUpdate(collectedDoc); // Our sync doc
We are hoping to skip these bits:
// This action converts it to a garbaged collected state
const collectedDoc = new Y.Doc({ gc: true });
Y.applyUpdate(collectedDoc, neverGarbageCollectedState);
Is there a more efficient way to do this straight from the non-gc’d doc?