Interface: WindowLike
API / @xmachines/play-router / WindowLike
Defined in: 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 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: types.ts:413
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (event) => void |
Returns
void
removeEventListener()
removeEventListener(type, listener): void;Defined in: types.ts:414
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (event) => void |
Returns
void