travels
    Preparing search index...

    Type Alias TravelsOptions<F, A, P, S>

    TravelsOptions: {
        autoArchive?: A;
        devtools?: (event: TravelsEvent<S, P>) => void;
        maxHistory?: number;
        mutable?: [F] extends [true] ? false : boolean;
        onBranchDiscard?: (event: TravelsBranchDiscardEvent<P>) => void;
        onError?: (error: Error) => void;
        onObserverError?: (event: TravelsObserverErrorEvent) => void;
        onWarning?: (warning: TravelsWarning) => void;
        warnOnUnsupportedState?: boolean;
    } & Omit<MutativeOptions<true, F>, "enablePatches"> & { patchesOptions?: P }

    Type Parameters

    • F extends boolean
    • A extends boolean
    • P extends PatchesOption = {}
    • S = any

    Type Declaration

    • OptionalautoArchive?: A

      Whether to automatically archive the current state, by default true

    • Optionaldevtools?: (event: TravelsEvent<S, P>) => void

      Optional hook for external devtools or debugging timelines. Factories type its event with the timeline state.

    • OptionalmaxHistory?: number

      The maximum number of history to keep, by default 10

    • Optionalmutable?: [F] extends [true] ? false : boolean

      Whether to mutate the state in place (for observable state like MobX, Vue, Pinia) When true, apply patches directly to the existing state object When false (default), create new immutable state objects

      Cannot be combined with enableAutoFreeze: true. TypeScript rejects the pair when the freeze flag is the literal true; the factories also reject it at runtime with INVALID_OPTION.

      false
      
    • OptionalonBranchDiscard?: (event: TravelsBranchDiscardEvent<P>) => void

      Called when undoing and then making a committed edit discards redo history. Root transactions report only entries that were visible before they began.

    • OptionalonError?: (error: Error) => void

      Called when Travels wraps a thrown core operation error. Errors raised by nested transactions are published after the root transaction settles.

    • OptionalonObserverError?: (event: TravelsObserverErrorEvent) => void

      Receives errors thrown by notification hooks. Observer errors never roll back or interrupt an already committed state transition.

    • OptionalonWarning?: (warning: TravelsWarning) => void

      Receives non-fatal normalization, compatibility, and migration warnings. Without this hook warnings are written to the console only in development.

    • OptionalwarnOnUnsupportedState?: boolean

      Warn in development about weak patch or JSON persistence semantics in state, retained patches, or history metadata. Defaults to true.

    • OptionalpatchesOptions?: P

      Configure patch formatting. Patches cannot be disabled because Travels uses them to implement history, navigation, and persistence.