Using the UndoFX library, I create an UndoManger as follows:
EventStream<DocumentChange<?>> changes = document.getChanges();
undoManager =
UndoManagerFactory.unlimitedHistoryUndoManager(
changes,
c -> c.redo(),
c -> c.undo(),
(c1, c2) -> c1.mergeWith(c2)
);
The ReactFX EventStream
returned by the document is created by merging a number of EventStreams which are available at document creation. For example,
documentChanges = EventStreams.merge(selectedSymbolChanges, symbolListChanges);
However, the document gets items added to it later, and those items include EventStreams that should also be published to the document EventStream. I've tried
documentChanges = EventStreams.merge(documentChanges, newObjectChanges);
However, changes in the newObjectChanges
EventStream never hit the UndoManager.
What is the best way to merge additional EventStreams into the UndoManger after it is already created? Or is this impossible (i.e., stream must be immutable)?
If the latter is the case, how does one create a stream for a dynamic number of objects that don't exist at UndoManager creation time?