# redux-sockets

> An integration between redux and socket.io

Latest version **1.1.1** (published 2017-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-sockets
pnpm add redux-sockets
yarn add redux-sockets
bun add redux-sockets
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2017-09-23 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Maintainers | sharongrossman |
| Keywords | redux, socket, socket.io, reducer |

## Links

- npm: https://www.npmjs.com/package/redux-sockets
- Repository: https://github.com/SharonGrossman/redux-sockets
- Homepage: https://github.com/SharonGrossman/redux-sockets#readme
- Issues: https://github.com/SharonGrossman/redux-sockets/issues
- npm.io page: https://npm.io/package/redux-sockets

## Dependencies (3)

- [redux-actions](https://npm.io/package/redux-actions.md) ^2.2.1
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.0.3
- [socketio-wildcard](https://npm.io/package/socketio-wildcard.md) ^2.0.0

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

- 1.1.1 (latest) — 2017-09-23
- 1.1.0 — 2017-08-01
- 1.0.0 — 2017-08-01

## README

# redux-sockets ![BuildStatus](https://travis-ci.org/SharonGrossman/redux-sockets.svg?branch=master)

## Install
```
npm install --save-dev redux-sockets
```

## Description
* A simple module to help simplify the integration of [socket.io](https://socket.io)
 with your [redux](http://redux.js.org/docs/introduction/) application
* Emits client actions to the server if a `socket` payload is presented
* Initializes socketio connection and handles connection actions to the server and client
* Listens to any socket event using `socketio-wildcard`
and dispatches the event to the client in the form of `server/ACTION_TYPE`

## Usage
The module exports a middleware and a reducer

### middleware
Add the middleware to the applyMiddleware function upon redux store initialization

```
import socketIoMiddleware from 'redux-sockets';
...
return createStore(
  ...
  applyMiddleware(socketIoMiddleware(), ...middlewares)
);
```
### reducer
Simply import and add the reducer to your other reducers
```
import {combineReducers} from 'redux';
import {reducer as socket} from 'redux-sockets';
...
export default combineReducers({
  ...
  socket
});
```

The module also exports the action ``` socketConnect``` ,
and action types ``` CONNECT, CONNECTED, DISCONNECTED```

## Why not [redux-socket.io](https://github.com/itaylor/redux-socket.io)?
redux-socket.io is great for capturing events from the server but I wanted more control
over the received actions and create a connection on demand (emitting a CONNECT action)
Also, with redux-socket.io you could only capture a single event name. 
This module captures all sorts of events.

## License

[MIT](LICENSE) © [Sharon Grossman](https://github.com/sharongrossman)

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