Skip to content

Commit c5426f1

Browse files
authored
Merge pull request #13 from sanfilippopablo/master
Added devToolsStateSanitizer with examples
2 parents a04946d + a7f9479 commit c5426f1

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

examples/chat/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import ReactDOM from 'react-dom'
33
import { createStore, compose, applyMiddleware } from 'redux'
44
import App from './components/App'
55
import counter from './reducers'
6-
import scuttlebutt from 'redux-scuttlebutt'
6+
import scuttlebutt, { devToolsStateSanitizer } from 'redux-scuttlebutt'
7+
8+
const devToolsConfig = {
9+
stateSanitizer: devToolsStateSanitizer
10+
}
711

812
const enhancer = compose(
913
applyMiddleware(scuttlebutt),
10-
window.devToolsExtension ? window.devToolsExtension() : f => f,
14+
window.devToolsExtension ? window.devToolsExtension(devToolsConfig) : f => f,
1115
)
1216

1317
const store = createStore(counter, undefined, enhancer)

examples/counter/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ import { createStore, compose, applyMiddleware } from 'redux'
44
import Counter from './components/Counter'
55
import App from './components/App'
66
import counter from './reducers'
7-
import scuttlebutt from 'redux-scuttlebutt'
7+
import scuttlebutt, { devToolsStateSanitizer } from 'redux-scuttlebutt'
8+
9+
const devToolsConfig = {
10+
stateSanitizer: devToolsStateSanitizer
11+
}
812

913
const enhancer = compose(
1014
scuttlebutt(),
11-
window.devToolsExtension ? window.devToolsExtension() : f => f,
15+
window.devToolsExtension ? window.devToolsExtension(devToolsConfig) : f => f,
1216
)
1317

1418
const store = createStore(counter, undefined, enhancer)

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ function connectStreams(io, createStream) {
134134
})
135135

136136
}
137+
138+
// devToolsStateSanitizer can be applied to the devToolsExtension
139+
// as the stateSanitizer to show correctly the store state instead
140+
// of showing the internal representation of redux-scuttlebutt
141+
export const devToolsStateSanitizer = (state) => state.slice(-1)[0][3]

0 commit comments

Comments
 (0)