Interface: WindowLike
API / @xmachines/play-svelte-spa-router / WindowLike
Defined in: play-router/src/types.ts:460
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 defaultconnectRouter({ actor, routeMap });
// SSR or a test — an injected mockconst 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:461
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (event) => void |
Returns
void
removeEventListener()
removeEventListener(type, listener): void;Defined in: play-router/src/types.ts:462
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (event) => void |
Returns
void