Skip to content

Commit 15ea5d3

Browse files
committed
Fixes initial state always being undefined
due to not using orderedHistory.getIntialState and setting to SOURCE index.
1 parent 9a38e30 commit 15ea5d3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ export default function scuttlebutt(options) {
2525
return (createStore) => {
2626
// is it more efficient to store previous states, or replay a bunch of
2727
// previous actions? (until we have COMMIT checkpointing, the former)
28-
const scuttlebutt = connectGossip(
29-
new Dispatcher(options.dispatcherOptions),
28+
const dispatcher = new Dispatcher(options.dispatcherOptions),
29+
scuttlebutt = connectGossip(
30+
dispatcher,
3031
options.uri,
3132
options.primusOptions,
3233
options.primus
3334
)
3435

35-
return (reducer, preloadedState, enhancer) => {
36+
return (reducer, initialState, enhancer) => {
3637
const store = createStore(
3738
scuttlebutt.wrapReducer(reducer),
38-
[[,,preloadedState]], // preloaded state is the earliest snapshot
39+
dispatcher.wrapInitialState(initialState), // preloaded state is the earliest snapshot
3940
enhancer)
4041

4142
return {

0 commit comments

Comments
 (0)