Skip to content

Commit 0e7c266

Browse files
committed
Adds options primusOptions and dispatcherOptions
and a shitty start to server documentation i want to abstract most of the annoying piping, in/out files, remote servers, primus/other connection, and boilerplate into lib/server to save everyone the hassle, and allow us to update it when bugs/api changes arise.
1 parent 6237c75 commit 0e7c266

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# 0.3.4
1+
# 0.3.4-0.3.5
22

3-
* Adds `server` options `connectRedux` and `getStatistics`
3+
* Adds `server` options `connectRedux`, `getStatistics`, `primusOptions` and
4+
`dispatcherOptions`
45

56
# 0.3.3
67

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-scuttlebutt",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "Redux distributed dispatcher",
55
"main": "lib/index.js",
66
"engines": {

server.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
```js
3+
var scuttlebutt = require('redux-scuttlebutt/lib/server').default
4+
var serverOptions = {}
5+
6+
scuttlebutt(server, serverOptions)
7+
```
8+
9+
# server options
10+
11+
### `dispatcherOptions` and `primusOptions`
12+
13+
## `connectRedux(gossip)`
14+
15+
gossip is a store enhancer, connect it to redux
16+
17+
## `getStatistics()`
18+
19+
return value will be called with (source, event), so you can render statistics
20+
21+
## env vars
22+
23+
### `INFILE`, `OUTFILE`
24+
25+
### `SB_REMOTE`

src/server.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ const INFILE = process.env['INFILE'],
77
const defaultOptions = {
88
connectRedux,
99
getStatistics,
10+
primusOptions: {},
11+
dispatcherOptions: {},
1012
}
1113

1214
export default function scuttlebuttServer(server, options) {
1315
options = { ...defaultOptions, ...options }
1416

15-
const primusServer = new (require('primus'))(server, {}),
17+
const primusServer = new (require('primus'))(server, options.primusOptions),
1618
Dispatcher = require('./dispatcher').default,
17-
gossip = new Dispatcher(),
18-
onStatistic = getStatistics()
19+
gossip = new Dispatcher(options.dispatcherOptions),
20+
onStatistic = options.getStatistics()
1921

2022
// connect dispatcher to redux
21-
connectRedux(gossip)
23+
options.connectRedux(gossip)
2224

2325
// read actions from file
2426
if (INFILE) {

0 commit comments

Comments
 (0)