Redux binding for Socket.IO
MIT License
Redux / React binding for Socket.io
This Is Still Alpha ❗
Please do not use in production. There are many moving parts missing.
npm install redux.io --save
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] )
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:
History:
0.2.0 - Breaking API changes, HoC Implementation.
0.1.0 - Initial Implementation.
License
MIT