Connection
Defined in: client.ts:195
WebSocket connection to a Lowlander server with type-safe RPC, automatic reconnection, and reactive updates.
Example
Section titled “Example”import type * as API from './server/api.js';const conn = new Connection<typeof API>('ws://localhost:8080/');
// Simple RPC - returns PromiseProxyconst sum = conn.api.add(1, 2);
// Server proxy for stateful APIsconst auth = conn.api.authenticate('token');const secret = auth.serverProxy.getSecret();
// Streaming with callbacksconn.api.streamData(data => console.log(data));
// Use within Aberdeen reactive scopes$(() => { dump(conn.isOnline()); dump(sum);});Type Parameters
Section titled “Type Parameters”T
The server-side API type (import from your server API file)
Indexable
Section titled “Indexable”[
key:number]:true
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Connection<
T>(url):Connection<T>
Defined in: client.ts:219
Parameters
Section titled “Parameters”string | (() => WebSocket)
WebSocket URL (e.g., ‘ws://localhost:8080/’), or a fake WebSocket object for testing
Returns
Section titled “Returns”Connection<T>
Properties
Section titled “Properties”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
Methods
Section titled “Methods”isOnline()
Section titled “isOnline()”isOnline():
boolean
Defined in: client.ts:227
Returns the current connection status. Reactive in Aberdeen scopes.
Returns
Section titled “Returns”boolean
getError()
Section titled “getError()”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.
Returns
Section titled “Returns”string