Skip to content

Separate document and history stores #2

Open
@martijnvermaat

Description

@martijnvermaat

Was: GitLab #7

I think it would be nice if the current DocumentStore would be split in:

  1. DocumentStore, containing just the open document.
  2. HistoryStore, containing undo and redo stacks of documents.

Let's ignore document view (focus etc) here.

I gave it a short try, but didn't yet come to a satisfactory setup. The main challenge seems to be to remove the need for bidirectional dependencies between the two stores.

Sketch setup

HistoryStore knows about DocumentStore, but not the other way around. Both listen for document change actions and HistoryStore waits for DocumentStore. It then stores a snapshot of the DocumentStore on its undo stack.

The HistoryStore exposes an undo object which contains a label and the complete state snapshot to revert to. The component can get this object and send it with an UNDO action so that it can arrive at the DocumentStore. To remove some undo/redo knowledge from the DocumentStore it could listen to SET_DOCUMENT actions or similar instead of UNDO, which could be spawned with some logic in the action creator.

I guess this would work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions