travels
    Preparing search index...

    Class Travels<S, F, A, P>

    Core Travels class for managing undo/redo history

    Type Parameters

    • S
    • F extends boolean = false
    • A extends boolean = true
    • P extends PatchesOption = {}
    Index

    Constructors

    • Type Parameters

      • S
      • F extends boolean = false
      • A extends boolean = true
      • P extends { arrayLengthAssignment?: boolean; pathAsArray?: boolean } = {}

      Parameters

      Returns Travels<S, F, A, P>

    Properties

    mutable: boolean

    Get the mutable mode

    Methods

    • Go back in the history

      Parameters

      • amount: number = 1

      Returns void

    • Check if it's possible to archive the current state

      Returns boolean

    • Check if it's possible to go back

      Returns boolean

    • Check if it's possible to go forward

      Returns boolean

    • Go forward in the history

      Parameters

      • amount: number = 1

      Returns void

    • Get the complete history of states

      Returns readonly S[]

      The history array. Reference equality indicates cache hit.

      IMPORTANT: Treat the returned array and every state entry as read-only. They are cached internally.

      • In development mode, only the array container is frozen.
      • State entries are shared cached snapshots and are not deep-frozen.
      • In production mode, modifying the array or its entries will corrupt the cache.
    • Get the current position in the history

      Returns number

    • Go to a specific position in the history

      Parameters

      • nextPosition: number

      Returns void

    • Remove all history and make the current state (including any unarchived temp patches) as the new initial state.

      This is a destructive operation that discards all history and overwrites the internal baseline. Future reset() calls will return to this snapshot.

      Returns void

    • Subscribe to state changes

      Parameters

      • listener: Listener<S, P>

      Returns () => void

      Unsubscribe function