Kvaser CanKing GUI Extensions SDK - v7.5.1
    Preparing search index...

    Interface IUndoObject<T>

    The undo/redo object. Includes the current state and methods to manipulate it.

    interface IUndoObject<T> {
        canRedo: () => boolean;
        canUndo: () => boolean;
        redo: () => void;
        reset: (current?: T, previous?: T[], next?: T[]) => void;
        set: (updater: T | ((curr?: T) => T)) => void;
        state: IUndoState<T>;
        subscribe?: (listener: () => void) => () => void;
        undo: () => void;
    }

    Type Parameters

    • T

      The type of the undo/redo data.

    Index

    Properties

    canRedo: () => boolean

    Check if redo is possible

    Type Declaration

      • (): boolean
      • Returns boolean

        true if there are states to redo to

    canUndo: () => boolean

    Check if undo is possible

    Type Declaration

      • (): boolean
      • Returns boolean

        true if there are states to undo to

    redo: () => void

    Redo to the next state

    reset: (current?: T, previous?: T[], next?: T[]) => void

    Reset the undo/redo history with a new initial value

    Type Declaration

      • (current?: T, previous?: T[], next?: T[]): void
      • Parameters

        • Optionalcurrent: T

          The new initial value. If undefined, current will be unset.

        • Optionalprevious: T[]

          The previous values (optional)

        • Optionalnext: T[]

          The next values (optional)

        Returns void

    set: (updater: T | ((curr?: T) => T)) => void

    Set a new current state

    Type Declaration

      • (updater: T | ((curr?: T) => T)): void
      • Parameters

        • updater: T | ((curr?: T) => T)

          The new value or a function that receives the current value and returns the new value

        Returns void

    state: IUndoState<T>

    The current undo/redo state

    subscribe?: (listener: () => void) => () => void

    Subscribe to state changes (optional, for triggering re-renders)

    Type Declaration

      • (listener: () => void): () => void
      • Parameters

        • listener: () => void

          Callback function that will be called whenever state changes

        Returns () => void

        Unsubscribe function

    undo: () => void

    Undo to the previous state