I want to have activities initiated by the user be completed by the server, and still undoable by the client.
Here is a simplified version of my code flow:
client:
ymap.set(uuid, candidateValue)
server:
ymap.observe((event)=>{
const uuid = event.changes.keys[0]
const candidateValue = ymap.get(uuid)
const persistedValue = persistToDatabase(candidateValue)
// replace candidate with persisted
ymap.delete(uuid)
ymap.set(persistedValue.id, persistedValue)
})
client:
undoManager.undo() // nothing happens
I would like the client to be able to delete the persisted key/value from the ymap by undoing.
To you so, the replace action should be done on behalf of the client from the server.
Is there a way to apply updates to a doc on behalf of a remote origin?