API Documentation • Docs
API Documentation / RouterHistory
Interface: RouterHistory
Alpha
Interface implemented by History implementations that can be passed to the router as Router.history
Properties
base
readonly
base:string
Alpha
Base path that is prepended to every url. This allows hosting an SPA at a sub-folder of a domain like example.com/sub-folder
by having a base
of /sub-folder
location
readonly
location:string
Alpha
Current History location
state
readonly
state:HistoryState
Alpha
Current History state
Methods
createHref()
createHref(
location
):string
Alpha
Parameters
• location: string
history location that should create an href
Returns
string
destroy()
destroy():
void
Alpha
Returns
void
go()
go(
delta
,triggerListeners
?):void
Alpha
Parameters
• delta: number
distance to travel. If delta is < 0, it will go back, if it's > 0, it will go forward by that amount of entries.
• triggerListeners?: boolean
whether this should trigger listeners attached to the history
Returns
void
Example
myHistory.go(-1) // equivalent to window.history.back()
myHistory.go(1) // equivalent to window.history.forward()
listen()
listen(
callback
): () =>void
Alpha
Parameters
• callback: NavigationCallback
listener to attach
Returns
Function
a callback to remove the listener
Returns
void
push()
push(
to
,data
?):void
Alpha
Parameters
• to: string
location to push
• data?: HistoryState
optional HistoryState to be associated with the navigation entry
Returns
void
replace()
replace(
to
,data
?):void
Alpha
Parameters
• to: string
location to set
• data?: HistoryState
optional HistoryState to be associated with the navigation entry
Returns
void