vapor-chamber API reference - v1.16.0
    Preparing search index...

    Function history

    • Parameters

      • options: {
            maxSize?: number;
            filter?: (cmd: Command) => boolean;
            bus?: CommandBus<CommandMap>;
            undoAction?: string;
            redoAction?: string;
        } = {}
        • OptionalmaxSize?: number
        • Optionalfilter?: (cmd: Command) => boolean
        • Optionalbus?: CommandBus<CommandMap>

          Reference to the command bus — enables undo() to execute inverse handlers

        • OptionalundoAction?: string

          Action name to register as the undo trigger (e.g. 'cart.undo'). The plugin registers the bus handler itself and ALWAYS excludes this action from recording — even if filter would match it. Without this, a hand-wired bus.register('cart.undo', () => h.undo()) records the trigger command into history (clearing the redo stack and burying real entries), so undo works once and redo never enables. Requires bus.

        • OptionalredoAction?: string

          Action name to register as the redo trigger. Same semantics as undoAction.

      Returns Plugin & {
          getState: () => HistoryState;
          undo: () => Command | undefined;
          redo: () => Command | undefined;
          clear: () => void;
          dispose: () => void;
      }

      • getState: () => HistoryState
      • undo: () => Command | undefined
      • redo: () => Command | undefined
      • clear: () => void
      • dispose: () => void

        Unregister the undoAction/redoAction bus handlers (no-op if none).