Skip to content

Interface: BrowserHistory

API / @xmachines/play-dom-router / BrowserHistory

Defined in: play-dom-router/src/create-browser-history.ts:3

Extended by

Properties

PropertyModifierTypeDescriptionDefined in
locationreadonlyobjectReturns the state of the current locationplay-dom-router/src/create-browser-history.ts:7
location.hashpublicstring-play-dom-router/src/create-browser-history.ts:10
location.pathnamepublicstring-play-dom-router/src/create-browser-history.ts:8
location.searchpublicstring-play-dom-router/src/create-browser-history.ts:9
location.statepublicunknown-play-dom-router/src/create-browser-history.ts:11

Methods

back()

back(): void;

Defined in: play-dom-router/src/create-browser-history.ts:28

Returns

void


createHref()

createHref(path): string;

Defined in: play-dom-router/src/create-browser-history.ts:46

Creates an href from a path

Parameters

ParameterType
pathstring

Returns

string


destroy()

destroy(): void;

Defined in: play-dom-router/src/create-browser-history.ts:54

Cleans up.

A second call is safe. When more than one wrapper shares the same window.history, the last wrapper restores the original methods.

Returns

void


forward()

forward(): void;

Defined in: play-dom-router/src/create-browser-history.ts:29

Returns

void


go()

go(delta): void;

Defined in: play-dom-router/src/create-browser-history.ts:27

Moves back or forward in the history

Parameters

ParameterType
deltanumber

Returns

void


push()

push(path, state?): void;

Defined in: play-dom-router/src/create-browser-history.ts:17

Pushes a new URL to the history

Parameters

ParameterType
pathstring
state?unknown

Returns

void


replace()

replace(path, state?): void;

Defined in: play-dom-router/src/create-browser-history.ts:22

Replaces the current URL in the history

Parameters

ParameterType
pathstring
state?unknown

Returns

void


subscribe()

subscribe(listener): () => void;

Defined in: play-dom-router/src/create-browser-history.ts:41

Subscribes to the history changes. It returns a function that cancels the subscription.

The return is a plain function here, because a consumer IMPLEMENTS this interface to inject its own history for a test or for SSR. A Cleanup return would refuse every implementation that hands a plain function back. DisposableBrowserHistory narrows it for the value that createBrowserHistory builds, which nothing implements.

Parameters

ParameterType
listener(location) => void

Returns

() => void