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;
go(delta: number): void;
listen(listener: Listener): () => void;
}§Methods
§
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