Interface History

A history abstraction.

interface History {
    location: Location;
    back(): void;
    push(to: To): void;
    replace(to: To): void;
    subscribe(listener: (() => void)): (() => void);
    toURL(location: Location, base?: string | URL): string;
}

Properties

location: Location

The current history location.

Methods

  • Move back to the previous history entry.

    Returns void

  • Adds an entry to the history stack.

    Parameters

    • to: To

      A location to navigate to.

    Returns void

  • Modifies the current history entry, replacing it with the state object and URL passed in the method parameters.

    Parameters

    • to: To

      A location to navigate to.

    Returns void

  • Subscribe to location changes.

    Parameters

    • listener: (() => void)

      A listener to subscribe.

        • (): void
        • Returns void

    Returns (() => void)

    A callback to unsubscribe a listener.

      • (): void
      • Returns void

  • Creates a URL for a given location.

    Parameters

    • location: Location

      A location to create a URL for.

    • Optionalbase: string | URL

      A URL base.

    Returns string