dimanche 28 juillet 2019

Implementing undo/redo in a d3 data model

I am working on an online editor using d3 for my data model. For implementing Undo/Redo I think that the easiest way is to save the whole model after each action. But the editor is aimed to edit large files where the model may contain several millions of elements and so this idea is causing memory issues.

My data model is an array. Because most edits are very local, it seems natural to save some local information to transform the model into the previous state. To implement this idea I was thinking of using something like edit distance and sequence alignment. Another way is to keep track of changes during any action but this solution, despite being more efficient, seems more error-prone to me. Is there any standard way of doing this which I am unaware of? I have studied these useful links:

  1. Undo/Redo implementation
  2. Memento Pattern

Aucun commentaire:

Enregistrer un commentaire