A WebSocket client that enables interaction via RxJS-like subscriptions. Version 0.1.3 is the current stable release. It automatically manages connection lifecycle: establishes connection on first subscribe, reconnects up to a configurable limit on unexpected disconnection, and closes when the last consumer unsubscribes. Differentiating features include observable-based message handling and built-in reconnection logic. Suitable for Node.js >=8.0.0.
npm install observable-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an ObservableWebSocket, subscribes with a consumer that logs incoming messages, sends a message, and after 2 seconds unsubscribes.
Use `{ consumer }` wrapper as shown in documentation.Use `{ data: payload }` format.Set to a finite number (e.g., 5) to limit reconnection attempts.
Ensure consumer uniqueness or track subscription state externally.
Use only the provided methods (subscribe, unsubscribe, send) for interaction.
Set `debug: false` in production.
Use `import { ObservableWebsocket } from 'observable-websocket'` (curly braces).Pass an object with `uri` property: `new ObservableWebsocket({ uri: 'wss://...' })`.Ensure named destructured import: `import { ObservableWebsocket } from 'observable-websocket'`.Wrap consumer in object: `ws.subscribe({ consumer: myFunc })`.No dependency data recorded yet.