Skip to content

Interface: WindowLike

API / @xmachines/play-svelte-spa-router / WindowLike

Defined in: play-router/src/types.ts:412

The minimal window interface of an adapter that subscribes to a DOM event, for example to hashchange. You can inject it for SSR and for a test: give a mock in place of the global window when no DOM is available.

The definition is structural, and it holds no reference to Window. This package therefore compiles without the DOM lib.

Example

// The normal use — the global window, which is the default
connectRouter({ actor, routeMap });
// SSR or a test — an injected mock
const mockWin: WindowLike = { addEventListener: vi.fn(), removeEventListener: vi.fn() };
connectRouter({ actor, routeMap, window: mockWin });

Methods

addEventListener()

addEventListener(type, listener): void;

Defined in: play-router/src/types.ts:413

Parameters

ParameterType
typestring
listener(event) => void

Returns

void


removeEventListener()

removeEventListener(type, listener): void;

Defined in: play-router/src/types.ts:414

Parameters

ParameterType
typestring
listener(event) => void

Returns

void