Registry / messaging / angular2-websocket

angular2-websocket

JSON →
library0.9.8jsnpmunverified

Angular 2+ WebSocket wrapper with RxJS Subject streams. Version 0.9.8 (latest since 2019) is built against Angular 2 and RxJS 5/6. Provides automatic reconnect, send modes (Direct, Observer, Promise), and binary type configuration. Differs from angular-websocket by targeting Angular 2+ with TypeScript. Requires peer dependencies: core-js, reflect-metadata, TypeScript 3.2, zone.js.

messaging
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.

Path must include full module path ending in 'angular2-websocket', not the package root.

import { $WebSocket } from 'angular2-websocket/angular2-websocket'

Same path requirement as $WebSocket.

import { WebSocketSendMode } from 'angular2-websocket/angular2-websocket'

RxJS 6 uses { Subject } from 'rxjs'; RxJS 5 path is deprecated.

import { Subject } from 'rxjs'

Basic usage: connect to a WebSocket, send a message, and handle incoming data using RxJS streams.

import { $WebSocket, WebSocketSendMode } from 'angular2-websocket/angular2-websocket'; import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-root', template: '' }) export class AppComponent implements OnInit { ngOnInit() { const ws = new $WebSocket('ws://echo.websocket.org'); ws.getDataStream().subscribe(msg => console.log('Received:', msg.data)); ws.send('Hello').subscribe(() => console.log('Sent')); ws.close(true); } }
Debug
Known footguns
deprecatedLibrary has not been updated since 2019; no official support for Angular 12+ or RxJS 7.
breakingImport path must include the full module: 'angular2-websocket/angular2-websocket'. Importing from package root fails.
gotchaDefault binary type is 'arrayBuffer', but documentation says 'blob'. Verify actual behavior.
breakingsend() returns an RxJS Observable that is cold by default; subscribers must call .publish().connect() to trigger send.
deprecatedRequires reflect-metadata polyfill which is no longer needed in Angular 13+ with zone.js 0.12.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources