Skip to content

Connection

Defined in: client.ts:195

WebSocket connection to a Lowlander server with type-safe RPC, automatic reconnection, and reactive updates.

import type * as API from './server/api.js';
const conn = new Connection<typeof API>('ws://localhost:8080/');
// Simple RPC - returns PromiseProxy
const sum = conn.api.add(1, 2);
// Server proxy for stateful APIs
const auth = conn.api.authenticate('token');
const secret = auth.serverProxy.getSecret();
// Streaming with callbacks
conn.api.streamData(data => console.log(data));
// Use within Aberdeen reactive scopes
$(() => {
dump(conn.isOnline());
dump(sum);
});

T

The server-side API type (import from your server API file)

[key: number]: true

new Connection<T>(url): Connection<T>

Defined in: client.ts:219

string | (() => WebSocket)

WebSocket URL (e.g., ‘ws://localhost:8080/’), or a fake WebSocket object for testing

Connection<T>

api: ClientProxyObject<T>

Defined in: client.ts:214

Type-safe proxy to the server-side API. Methods return PromiseProxy objects that work reactively in Aberdeen scopes. ServerProxy returns include a .serverProxy property for accessing stateful server APIs.


url: string | (() => WebSocket)

Defined in: client.ts:219

WebSocket URL (e.g., ‘ws://localhost:8080/’), or a fake WebSocket object for testing

isOnline(): boolean

Defined in: client.ts:227

Returns the current connection status. Reactive in Aberdeen scopes.

boolean


getError(): string

Defined in: client.ts:233

Returns the last WebSocket error message, or undefined if there is none. Clears automatically when the connection comes online. Reactive in Aberdeen scopes.

string