Skip to content

Commit 64bfa1e

Browse files
committed
Merge pull request #65 from minedeljkovic/deserialize-callbacks
add deserialize callbacks for persistState
2 parents f05719d + 20b5065 commit 64bfa1e

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ If you do not know what [Redux DevTools](https://github.com/gaearon/redux-devtoo
8181
`window.devToolsExtension([config])`
8282
- **config** arguments (optional)
8383
- **name** (*string*) - the instance name to be showed on the monitor page. Default value is `document.title`.
84+
- **deserializeState(state): transformedState** (*function*) - optional transformation of state deserialized from debug session (useful if state is not plain object. Example: immutable-js state)
85+
- state, transformedState - Redux state objects
86+
- **deserializeAction(action): transformedAction** (*function*) - optional transformation of actions deserialized from debug session (useful if actions are not plain object. Example: immutable-js action payload)
87+
- action, transformedAction - Redux action objects
8488

8589
## Examples
8690
Open these urls to test the extension:

src/app/store/configureStore.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { compose } from 'redux';
22
import { persistState, instrument } from 'redux-devtools';
33

4-
export default function configureStore(next, subscriber = () => ({})) {
4+
export default function configureStore(next, subscriber = () => ({}), options = {}) {
5+
const { deserializeState, deserializeAction } = options;
56
return compose(
67
instrument(subscriber),
78
persistState(
8-
getPersistSession()
9+
getPersistSession(),
10+
deserializeState,
11+
deserializeAction
912
)
1013
)(next);
1114
}

src/browser/extension/inject/pageScript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ window.devToolsExtension = function(config = {}) {
140140
return (reducer, initialState, enhancer) => {
141141
if (!isAllowed(window.devToolsOptions)) return next(reducer, initialState, enhancer);
142142

143-
store = configureStore(next, monitorReducer)(reducer, initialState, enhancer);
143+
const { deserializeState, deserializeAction } = config;
144+
store = configureStore(next, monitorReducer, {
145+
deserializeState,
146+
deserializeAction
147+
})(reducer, initialState, enhancer);
144148
init();
145149
store.subscribe(() => { handleChange(store.getState(), store.liftedStore.getState()); });
146150
return store;

0 commit comments

Comments
 (0)