# socket.io-client-xcontrol

> A Controller for the socket.io client

Latest version **0.0.2** (published 2018-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install socket.io-client-xcontrol
pnpm add socket.io-client-xcontrol
yarn add socket.io-client-xcontrol
bun add socket.io-client-xcontrol
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2018-04-02 |
| First published | 2018-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | thk2b |
| Maintainers | thk2b |
| Keywords | socket.io-client, xcontrol |

## Links

- npm: https://www.npmjs.com/package/socket.io-client-xcontrol
- Repository: https://github.com/thk2b/socket.io-client-xcontrol
- Homepage: https://github.com/thk2b/socket.io-client-xcontrol#readme
- Issues: https://github.com/thk2b/socket.io-client-xcontrol/issues
- npm.io page: https://npm.io/package/socket.io-client-xcontrol

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2018-04-02
- 0.0.1 — 2018-04-02
- 0.0.0 — 2018-04-02

## README

# 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)

```js
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)

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

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

const todos = new ConnectedTodos(socket)
```
Equivalent to:
```js
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)
    }
}
```

---
_Source: https://npm.io/package/socket.io-client-xcontrol · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
