BrowserHistory

sealed external interface BrowserHistory : UrlHistory(source)

A browser history stores the current location in regular URLs in a web browser environment. This is the standard for most web apps and provides the cleanest URLs the browser's address bar.

See also

https

://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory

Properties

Link copied to clipboard
abstract val action: Action

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.

Link copied to clipboard
abstract val location: Location<*>

The current location. This value is mutable.

Functions

Link copied to clipboard
abstract fun createHref(to: To): String

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

Link copied to clipboard
abstract fun createURL(to: To): URL

Returns a URL for the given to value

Link copied to clipboard
abstract fun encodeLocation(to: To): Path

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

Link copied to clipboard
abstract fun go(delta: Double)

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

Link copied to clipboard
abstract fun listen(listener: Listener): () -> Unit

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

Link copied to clipboard
abstract fun push(to: To, state: Any? = definedExternally)

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.

Link copied to clipboard
abstract fun replace(to: To, state: Any? = definedExternally)

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