travels
    Preparing search index...

    Type Alias TravelsOptions<F, A, P>

    TravelsOptions: {
        autoArchive?: A;
        devtools?: (event: TravelsDevtoolsEvent<any, P>) => void;
        history?: TravelsHistory<P>;
        initialPatches?: TravelPatches<P>;
        initialPosition?: number;
        maxHistory?: number;
        mutable?: boolean;
        onBranchDiscard?: (event: TravelsBranchDiscardEvent<P>) => void;
        onError?: (error: Error) => void;
        strictInitialPatches?: boolean;
        warnOnUnsupportedState?: boolean;
    } & Omit<MutativeOptions<true, F>, "enablePatches"> & { patchesOptions?: P }

    Type Parameters

    Type Declaration

    • OptionalautoArchive?: A

      Whether to automatically archive the current state, by default true

    • Optionaldevtools?: (event: TravelsDevtoolsEvent<any, P>) => void

      Optional hook for external devtools or debugging timelines.

    • Optionalhistory?: TravelsHistory<P>

      Restore validated serialized history. This is equivalent to passing initialPatches and initialPosition directly, but preserves the first-class persistence API shape returned by Travels.deserialize(...).

    • OptionalinitialPatches?: TravelPatches<P>

      The initial patches of the history

    • OptionalinitialPosition?: number

      The initial position in the history, by default 0

    • OptionalmaxHistory?: number

      The maximum number of history to keep, by default 10

    • Optionalmutable?: 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

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

      Called when undoing and then making a new edit discards redo history.

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

      Called when Travels wraps a thrown core operation error.

    • OptionalstrictInitialPatches?: boolean

      Whether to throw when initialPatches is invalid. When false (default), invalid patches are discarded and history starts empty.

    • OptionalwarnOnUnsupportedState?: boolean

      Whether to warn in development when state contains values with weak patch or JSON persistence semantics, by default true in development.

    • OptionalpatchesOptions?: P