/**
* Nexus Connect — Client-side $socket() rune.
*
* Connects to /_nexus/connect/:topic via SSE and returns a reactive
* state object whose .value updates in real time whenever the server publishes.
*
* Usage in a .nx island:
*
*
Global captures: {captures.value.count}
*/
export interface SocketState {
/** Current value — reactive in island components */
readonly value: T;
/** Register a callback that fires on every update */
subscribe: (fn: (value: T, prev: T) => void) => () => void;
/** Manually close the SSE connection */
close: () => void;
/** true while the SSE connection is establishing */
readonly connecting: boolean;
/** true if the connection is live */
readonly connected: boolean;
}
export interface SocketOptions {
default: T;
/** Optional transform applied to the raw JSON payload */
transform?: (raw: unknown) => T;
/** Called on SSE connection error */
onError?: (err: Event) => void;
/** Reconnect automatically on error (default: true) */
reconnect?: boolean;
}
export declare function $socket(topic: string, opts: SocketOptions): SocketState;
//# sourceMappingURL=client.d.ts.map