Skip to content

@jsvision/ui / Route

Interface: Route<P>

Defined in: ui/src/router/types.ts:139

A route definition: how to build the screen for a set of params, plus optional keep-alive, focus, and (de)serialization behavior.

Example

ts
const detail: Route<{ id: number }> = {
  build: (ctx) => ({ view: new DetailScreen(ctx.params.id) }),
  keepAlive: false,
  serialize: (p) => `id=${p.id}`,
  parse: (s) => ({ id: Number(new URLSearchParams(s).get('id')) }),
};

Type Parameters

P

P

Properties

build

build: (ctx) => ScreenBundle

Defined in: ui/src/router/types.ts:141

Build this route's screen bundle for the given params. Called on each activation unless kept alive.

Parameters

ctx

RouteContext<P>

Returns

ScreenBundle


focusKey?

optional focusKey?: (view) => string

Defined in: ui/src/router/types.ts:145

Optional exact-restore key: derive a stable key from the focused view so focus survives a rebuild.

Parameters

view

View

Returns

string


keepAlive?

optional keepAlive?: boolean

Defined in: ui/src/router/types.ts:143

Keep the screen mounted-but-hidden when navigating away, so its state survives a round-trip. Default off.


parse?

optional parse?: (s) => P

Defined in: ui/src/router/types.ts:149

Optional codec: parse this route's params back from a string.

Parameters

s

string

Returns

P


serialize?

optional serialize?: (params) => string

Defined in: ui/src/router/types.ts:147

Optional codec: serialize this route's params to a string (designed for deep-linking).

Parameters

params

P

Returns

string