Registry / communication / customapp-rxjs-websocket

customapp-rxjs-websocket

JSON →
library1.2.3jsnpmunverified

A package for managing WebSocket lifecycle with RxJS, inspired by Angular's WebSocket module but framework-agnostic. Current stable version 1.2.3, released monthly. Key differentiator: automatic reconnection, heartbeat, and message queuing handling in a single observable pipeline. Built for browsers and Node.js environments, ships TypeScript types.

npm install customapp-rxjs-websocket
INSTALL
IMPORT
SIG · CUSTOMAPP-RXJS-WEB
C
customapp-rxjs-websocket
communicationjavascriptv1.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebSocketClient
✓ import { WebSocketClient } from 'customapp-rxjs-websocket'
✗ import { WebSocketClient } from 'customapp-rxjs-websocket' - correct, but ensure import is at top level
Default export removed in v2; only named exports.
ConnectionStatus
✓ import { ConnectionStatus } from 'customapp-rxjs-websocket'
Enum for connection states: Connected, Disconnected, Reconnecting.
WebSocketModule
✓ import { WebSocketModule } from 'customapp-rxjs-websocket'
✗ import { WebSocketModule } from 'customapp-rxjs-websocket' - only available if using Angular module imports
Optional Angular compatibility module, not required for non-Angular usage.

Demonstrates creating a WebSocket client with reconnection, heartbeat, and message handling.

import { WebSocketClient } from 'customapp-rxjs-websocket'; import { webSocket } from 'rxjs/webSocket'; const wsClient = new WebSocketClient({ url: 'wss://example.com/ws', reconnectInterval: 5000, maxReconnectAttempts: 10, heartbeatInterval: 30000 }); wsClient.messages$.subscribe({ next: (msg) => console.log('Received:', msg), error: (err) => console.error('Error:', err), complete: () => console.log('Connection closed') }); wsClient.connect(); setTimeout(() => wsClient.send({ event: 'ping' }), 1000); setTimeout(() => wsClient.close(), 60000);
Debug
Known issues
breakingv2.0.0: Removed default export, WebSocketClient must be imported as named export.
fix
Use import { WebSocketClient } from 'customapp-rxjs-websocket' instead of import WebSocketClient from ...
affects: >=2.0.0
deprecatedv1.x: ConnectionStatus enum values are deprecated in favor of string literals.
fix
Use 'connected' | 'disconnected' | 'reconnecting' instead of ConnectionStatus.CONNECTED.
affects: >=1.0.0 <2.0.0
gotchaUnexpected token: operator required for rxjs v7 compatibility when using pipe with WebSocketClient.
fix
Ensure you import necessary operators: import { filter, map } from 'rxjs/operators'.
affects: >=1.0.0
gotchaWebSocketClient does not support binary data (ArrayBuffer) by default. Only JSON messages.
fix
Use custom serializer/deserializer options if binary messages are required.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: customapp-rxjs-websocket_1.WebSocketClient is not a constructor
Using CommonJS require() instead of ESM import
fix
Use import { WebSocketClient } from 'customapp-rxjs-websocket' instead of const { WebSocketClient } = require(...). Ensure your project is set to ES module.
Error: No provider for WebSocketClient - Angular 16+
Forgetting to import WebSocketModule in standalone component
fix
Add WebSocketModule to imports array in your Angular module or component imports.
Uncaught (in promise): Error: WebSocket connection to 'wss://...' failed: WebSocket is closed before the connection is established.
Initial connect() call before subscribing to messages or connection status
fix
Ensure you subscribe to messages$ or status$ before calling connect(), or wait for connection status.
rxjs-compat/observable/dom/webSocket is not a function
Mixing rxjs v6 compatibility layer with v7
fix
Install rxjs-compat if using v6 patterns, or migrate to v7: import { webSocket } from 'rxjs/webSocket'.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies
rxjsrequiredPeer dependency for Observable-based WebSocket integration
Agent activity
47 hits · last 30 days
node
42
OpenAI (training)
1
Resources
customapp-rxjs-websocket — npm install customapp-rxjs-websocket · libregistry