Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

History

A history is an interface to the navigation stack. The history serves as the source of truth for the current location, as well as provides a set of methods that may be used to change it.

It is similar to the DOM's window.history object, but with a smaller, more focused API.

interface History {
readonly action: Action;
readonly location: Location;
createHref(to: To): string;
createURL(to: To): URL;
encodeLocation(to: To): Path;
go(delta: number): void;
listen(listener: Listener): () => void;
push(to: To, state?: any): void;
replace(to: To, state?: any): void;
}

§Properties

§
readonly action: Action
[src]

The last action that modified the current location. This will always be Action.Pop when a history instance is first created. This value is mutable.

§
readonly location: Location
[src]

The current location. This value is mutable.

§Methods

§
createHref(to: To): string
[src]

Returns a valid href for the given to value that may be used as the value of an attribute.

@param to
  • The destination URL
§
createURL(to: To): URL
[src]

Returns a URL for the given to value

@param to
  • The destination URL
§
encodeLocation(to: To): Path
[src]

Encode a location the same way window.history would do (no-op for memory history) so we ensure our PUSH/REPLACE navigations for data routers behave the same as POP

@param to

Unencoded path

§
go(delta: number): void
[src]

Navigates n entries backward/forward in the history stack relative to the current index. For example, a "back" navigation would use go(-1).

@param delta
  • The delta in the stack index
§
listen(listener: Listener): () => void
[src]

Sets up a listener that will be called whenever the current location changes.

@param listener
  • A function that will be called when the location changes
@return

unlisten - A function that may be used to stop listening

§
push(to: To, state?: any): void
[src]

Pushes a new location onto the history stack, increasing its length by one. If there were any entries in the stack after the current one, they are lost.

@param to
  • The new URL
@param state
  • Data to associate with the new location
§
replace(to: To, state?: any): void
[src]

Replaces the current location in the history stack with a new one. The location that was replaced will no longer be available.

@param to
  • The new URL
@param state
  • Data to associate with the new location