Skip to main content

UrlState

Reads and writes the shareable state in the page address, using the hash and history.replaceState only, so history is never spammed. Writes are debounced inside the real adapter. Parsing and serialising live in core.

This is an interface exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import type { UrlState } from "@mapcairn/core";

interface UrlState

Methods​

link(value: UrlStateValue): string;

The full address that would show value: this page's address with its hash replaced by the one value makes. It changes nothing, so a link can carry more than the address bar does.

  • value (UrlStateValue)

read​

read(): UrlStateValue;

The shareable state the address holds now. A part that is missing or unreadable is left out.

write​

write(value: UrlStateValue): void;

Replaces the shareable state in the address. It does not merge with what is there.

  • value (UrlStateValue)

See also​

Source: packages/core/src/ports/url.ts:42