Registry / messaging / rxwebsocket

rxwebsocket

JSON →
library1.0.7jsnpmunverified

RxWebSocket v1.0.7 is an advanced RxJS WebSocket wrapper that replaces the standard WebSocketSubject with separate input/output types, reconnection with exponential backoff, message buffering during reconnect, keep-alive support, connection state tracking, and debug logging. It ships TypeScript types and supports both ESM and CJS. Released in 2021, it has no recent updates and only depends on rxjs. Key differentiators from RxJS built-in: generic type safety for send/receive, built-in reconnect logic, and buffered multiplex subscriptions.

npm install rxwebsocket
INSTALL
IMPORT
SIG · RXWEBSOCKET
R
rxwebsocket
messagingjavascriptv1.0.7
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.

RxWebSocketSubject
import { RxWebSocketSubject } from 'rxwebsocket'
import RxWebSocketSubject from 'rxwebsocket'
Named export, not default. Works with both ESM and CJS.
rxWebSocket
import { rxWebSocket } from 'rxwebsocket'
const { rxWebSocket } = require('rxwebsocket')
Factory function. Named export only. CJS require will work but Tree-Shaking may not.
RxWebSocketSubjectConfig
import { RxWebSocketSubjectConfig } from 'rxwebsocket'
import { RxWebSocketSubjectConfig } from 'rxjs/webSocket'
Config type extends RxJS's WebSocketSubjectConfig. Only available from rxwebsocket.

Creates a typed WebSocket with reconnection, state tracking, and sends a message then logs incoming messages.

import { rxWebSocket } from 'rxwebsocket'; interface Input { type: string; payload?: unknown } interface Output { data: unknown } const config = { url: 'wss://echo.websocket.org', debug: true, maxAttempts: 5, maxDelay: 30000, delay: 1000, keepAlive: false, }; const socket$ = rxWebSocket<Input, Output>(config); socket$.state$.subscribe({ next: (state) => console.log('State:', state), }); socket$.next({ type: 'ping' }); socket$.subscribe({ next: (msg) => console.log('Received:', msg), error: (err) => console.error('Error:', err), });
Debug
Known issues
gotchaType parameters for rxWebSocket or RxWebSocketSubject are required to get separate input/output types; omitting them defaults to unknown/any, losing type safety.
fix
Always specify generic types: rxWebSocket<InputType, OutputType>(config)
affects: >=1.0.0
deprecatedThe package has not been updated since 2021 and may have compatibility issues with newer RxJS versions (v7+).
fix
Consider using RxJS's built-in webSocket with custom reconnect logic, or test with your RxJS version.
affects: >=1.0.0
gotchaThe debug option logs all messages and state changes via console.debug, which may not be visible in production environments unless console.debug is enabled.
fix
Enable verbose logging with localStorage.debug = 'rxwebsocket:*' or similar if using custom logger.
affects: >=1.0.0
gotchaWhen using multiplex, the subscribe message is buffered and automatically re-sent on reconnect, but the unsubscribe message is not buffered and may be lost if sent during a disconnect.
fix
Ensure the socket is connected before sending unsubscribe, or handle cleanup manually.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Can't resolve 'rxwebsocket'
Missing npm install or wrong import path.
fix
Run 'npm install rxwebsocket' or ensure import path is correct.
TypeError: rxwebsocket_1.rxWebSocket is not a function
Incorrect import style (default instead of named import).
fix
Use named import: import { rxWebSocket } from 'rxwebsocket'
Property 'state$' does not exist on type 'WebSocketSubject<unknown>'
Using RxJS's WebSocketSubject instead of RxWebSocketSubject from rxwebsocket.
fix
Import RxWebSocketSubject from 'rxwebsocket' instead.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
rxjsrequiredpeer dependency; RxWebSocket extends RxJS WebSocketSubject and requires rxjs operators and observables.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
rxwebsocket — npm install rxwebsocket · libregistry