Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@customjs/ws

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@customjs/ws

`import { WsModule } from '@customjs/ws';`

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

WebSocket Service

import { WsModule } from '@customjs/ws';

This module provides a service to communicate with WebSockets in a reactive way.

The service handles error, close, receiveing and sending messages.

Usage

Javascript


  const WS_HOST = 'ws://echo.websocket.org';

  ...

  wsConnection: OpenConnection<any>;

  constructor(
    private ws: WsService
  ) { }

  ngOnInit() {
    this.wsConnection = this.ws.connect(WS_HOST);
  }

  sendMessage() {
    if (this.wsConnection && this.messageToSend) {
      this.wsConnection.channel.send(this.messageToSend);
      this.messageToSend = undefined;
    }
  }

Html

<div *ngIf="(wsConnection.message | async) as message">
  <h3>Last message</h3>
  {{ message }}
</div>

FAQs

Package last updated on 28 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts