0.0.25 • Published 10 years ago

redux-socket-create-listeners v0.0.25

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

redux-socket-create-listeners

A utility to initialize server-side socket.io listeners acoording to a set of redux-socket handlers. Be sure to check out the readme at redux-socket too!

Basically:

import login from './handlers/login';
import createStore from './redux-create';
import createServerListeners from 'redux-socket-create-listeners';

const initListenersFor = createServerListeners({login});

io.on('connection', socket => {
	reduxStore = createStore();
	initListenersFor(socket, reduxStore);
});

Now you can write handlers as promise returning functions:

// handlers/login.js
export default store => data =>
	Promise.resolve({message: 'success'});

And a redux action will be created automatically with that handler's name as type! In this case:

{
	type: 'login',
	message: 'success',
}

And it will be sent to the client too! (don't forget to use redux-socket there).

This way, you can write a universal reducer that makes sense (maybe?). Be sure to leave your feedback, i'll possibly make a decent readme in the future :P

Installation

npm install -S redux-socket-create-listeners

Example usage:

2Post

0.0.25

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.21

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago