Skip to content

Francois-Esquire/redux.io

Repository files navigation

redux.io

npm Build Status

Redux / React binding for Socket.io

This Is Still Alpha ❗

Please do not use in production. There are many moving parts missing.


Installation

npm install redux.io --save

Usage

An Example Can Be Found Here

This is what comes out of the box:

import { reducer, withSocket } from 'redux.io';
// or
const { reducer, withSocket } = require('redux.io');

reducer ( io [, defaultOptions] )

  • io (socket.io)
  • defaultOptions (Object)

It's up to you on how socket.io is delivered to the client. The only requirement is to pass socket.io to the redux.io reducer as the first parameter.

import { createStore, combineReducers } from 'redux';

import { reducer as socket } from 'redux.io';

/* Get your reference to Socket.io. */

/* Whether you're bundling with the client: */
import io from 'socket.io-client';

/* Or if you're having the file served: */
const io = window.io;

const rootReducer = combineReducers({
  socket: socket(io),
});

const store = createStore(rootReducer);

The complete of options as well as the defaultOptions list can be found here.

withSocket ( url [, options] ) ( Component [, wrapperConfig] )

  • url (String)

  • options (Object || Function (ownProps))

  • Component (React element) optional

  • wrapperConfig (object) optional

it's worthwhile to explore the socket.io library if you're new to it. check it out.


TODO:

  • Complete Test Cases
  • Complete Documentation

History:

  • 0.2.0 - Breaking API changes, HoC Implementation.

  • 0.1.0 - Initial Implementation.

License

MIT

Releases

No releases published

Packages

No packages published