https://github.com/vutran/redux-ipc
Log your Redux state and actions to a node backend via WebSockets.
https://github.com/vutran/redux-ipc
ipc node react redux websocket
Last synced: about 1 year ago
JSON representation
Log your Redux state and actions to a node backend via WebSockets.
- Host: GitHub
- URL: https://github.com/vutran/redux-ipc
- Owner: vutran
- License: mit
- Created: 2016-08-19T06:15:44.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-01T19:18:30.000Z (over 9 years ago)
- Last Synced: 2024-10-14T06:30:39.314Z (over 1 year ago)
- Topics: ipc, node, react, redux, websocket
- Language: JavaScript
- Homepage:
- Size: 1.09 MB
- Stars: 2
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-ipc
[](LICENSE)
> Log your Redux state and actions to a node backend via WebSockets.
## Install
```bash
$ npm install --save redux-ipc
```

## Usage
Apply the middleware when creating your Redux store.
```js
const reduxIpcMiddleware = require('redux-ipc');
const state = {
todos: [],
};
// apply the middleware
const store = createStore(state, {}, applyMiddleware(reduxIpcMiddleware));
// dispatch actions
// store.dispatch(...);
// store.dispatch(...);
// store.dispatch(...);
```
Create the server to listen for messages.
```js
const Server = require('redux-ipc').Server;
const PORT = process.env.REDUX_IPC_PORT || 8080;
const PROTOCOL = process.env.REDUX_IPC_PROTOCOL || 'redux-ipc';
// create a new redux ipc server
const wss = new Server({ port: PORT, socketName: PROTOCOL });
// listen to messages
wss.on('message', message => {
console.log(message);
});
```
## Examples
Run `npm install` and `npm start` for each directory in `/examples`.
*Note: Examples are based on the official Redux examples with slight modifications to showcase the IPC functionality.*
## License
MIT © Vu Tran