@epikodelabs/streamix / networking/src/public-api / webSocket
Function: webSocket()
webSocket<
T>(url,factory?):WebSocketStream<T>
Defined in: projects/libraries/streamix/networking/src/lib/webSocket.ts:87
Creates a reactive WebSocket stream.
Features:
- Bidirectional messaging
- Automatic send queue while connecting
- Async URL / socket factory support
- Proper stream termination semantics
- AbortSignal support
- Cleanup-safe event handling
Incoming WebSocket messages are expected to be JSON encoded. Outgoing messages are automatically serialized with JSON.stringify.
Type Parameters
T
T = any
Message payload type.
Parameters
url
MaybePromise<string>
WebSocket URL or async URL provider.
factory?
(url) => MaybePromise<WebSocket>
Optional WebSocket factory for dependency injection or testing.
Returns
A WebSocketStream instance.