New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

socket.io-client-xcontrol

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

socket.io-client-xcontrol

A Controller for the socket.io client

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

socket.io-client-xcontrol

A Controller for the socket.io client

Goal

The goal of this package is to connect a websocket to a controller. Whenever specific actions are caused on a controller instance, messages should be emited through the socket.

Implementation (A)

The SocketIo function takes a socket and returns a function that takes controllers and action names. This HOC recieves and emits side effects through the socket. The HOC listens for these actions on the socket, and triggers them on the controller when they are recieved. It also listens for these actions on the controller, and emits them through the socket.

Usage (A)

import SocketIo from 'socket.io-client-xcontrol'

SocketIo( socket )({ controller }, ['create', 'delete', 'update'])

Implementation (B)

The SocketIo function takes a Controller class and method names, and returns a new class to be initialized with a socket. This HOC overides the named methods and emits the method name, arguments and controller name through the socket. When initialized, the HOC listens for these actions on the socket, and triggers them on the controller when they are recieved. It also listens for these actions on the controller, and emits them through the socket.

Usage (B)

import SocketIo from 'socket.io-client-xcontrol'

const ConnectedTodos = SocketIo( Todos , ['create', 'delete', 'update'])

const todos = new ConnectedTodos(socket)

Equivalent to:

class Todos extends HashMap {
    constructor(initialState, socket){
      super(initialState)
      this.socket = socket
      socket.on('@@todos__create', args => this.create(args))
    }
    create(...args){
       super.create(...args)
       this.socket.emit('@@todos__create', args)
    }
}

Keywords

FAQs

Package last updated on 02 Apr 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc