🚀 DAY 1 OF LAUNCH WEEK: Reachability for Ruby Now in Beta.Learn more →
Socket
Book a DemoInstallSign in
Socket

@conclurer/web-socket

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@conclurer/web-socket

This module includes `WebSocketProvider` which is used to handle web socket connections between Edelog and a server.

latest
npmnpm
Version
6.8.0-beta.1
Version published
Maintainers
2
Created
Source

Web Socket Module

This module includes WebSocketProvider which is used to handle web socket connections between Edelog and a server.

How to Use

To use this module and WebSocketProvider you have to provide a custom implementation of WebSocketProvider like this:

import {NgModule} from '@angular/core';
import {WebSocketProvider} from '@conclurer/web-socket';

@NgModule({
  providers: [
    {provide: WebSocketProvider, useClass: YourImplementation},
  ],
})
export class YourModule {
}

This module includes a default provider for web sockets that works with Rails's ActionCable framework.

You can use the default provider like this:

import {NgModule} from '@angular/core';
import {WebSocketModule} from '@conclurer/web-socket';

@NgModule({
  imports: [
    WebSocketModule.withDefaultProviders(),
  ],
})
export class YourModule {
}

Stream Data

To stream data, you can use the stream function of WebSocketProvider:

import {Component, OnInit} from '@angular/core';
import {WebSocketProvider} from '@conclurer/web-socket';

@Component()
export class YourComponent implements OnInit {
  constructor(
    private readonly socket: WebSocketProvider,
  ) {
  }

  public ngOnInit() {
    const channel = this.socket.channel('your-channel-name');

    // Subscribe to incoming messages
    channel.incomingMessage$.subscribe(message => {
      console.log('INCOMING MESSAGE:', message);
    });

    // Push messages to channel
    channel.push('your-message', {optional: 'data'});
  }
}

FAQs

Package last updated on 31 Oct 2021

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