Skip to content

Commit

Permalink
Rename to actionSanitizer / stateSanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
zalmoxisus committed Aug 30, 2016
1 parent 1c5d785 commit b1f2ec9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ Name | Description
`secure` | *Boolean* specifies whether to use `https` protocol for [`remotedev-server`](https://github.com/zalmoxisus/remotedev-server).
`maxAge` | *Number* of maximum allowed actions to be stored on the history tree, the oldest actions are removed once maxAge is reached. Default is `30`.
`filters` | *Map of arrays* named `whitelist` or `blacklist` to filter action types. See the example bellow.
`actionsFilter` | *Function* which takes action object and id number as arguments, and should return action object back. See the example bellow.
`statesFilter` | *Function* which takes state object and index as arguments, and should return state object back. See the example bellow.
`actionSanitizer` | *Function* which takes action object and id number as arguments, and should return action object back. See the example bellow.
`stateSanitizer` | *Function* which takes state object and index as arguments, and should return state object back. See the example bellow.
`startOn` | *String* or *Array of strings* indicating an action or a list of actions, which should start remote monitoring (when `realtime` is `false`).
`stopOn` | *String* or *Array of strings* indicating an action or a list of actions, which should stop remote monitoring.
`sendOn` | *String* or *Array of strings* indicating an action or a list of actions, which should trigger sending the history to the monitor (without starting it). *Note*: when using it, add a `fetch` polyfill if needed.
Expand All @@ -107,11 +107,11 @@ export default function configureStore(initialState) {
name: 'Android app', realtime: true,
hostname: 'localhost', port: 8000,
maxAge: 30, filters: { blacklist: ['EFFECT_RESOLVED'] },
actionsFilter: (action) => (
actionSanitizer: (action) => (
action.type === 'FILE_DOWNLOAD_SUCCESS' && action.data ?
{ ...action, data: '<<LONG_BLOB>>' } : action
),
statesFilter: (state) => state.data ? { ...state, data: '<<LONG_BLOB>>' } : state
stateSanitizer: (state) => state.data ? { ...state, data: '<<LONG_BLOB>>' } : state
})
);
// If you have other enhancers & middlewares
Expand Down
12 changes: 6 additions & 6 deletions src/devTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ let sendOnError;
let sendTo;
let lastErrorMsg;
let actionCreators;
let statesFilter;
let actionsFilter;
let stateSanitizer;
let actionSanitizer;

function getLiftedState() {
return filterStagedActions(store.liftedStore.getState(), filters);
Expand Down Expand Up @@ -68,11 +68,11 @@ function relay(type, state, action, nextActionId) {
};
if (state) {
message.payload = type === 'ERROR' ? state :
stringify(filterState(state, type, filters, statesFilter, actionsFilter, nextActionId));
stringify(filterState(state, type, filters, stateSanitizer, actionSanitizer, nextActionId));
}
if (type === 'ACTION') {
message.action = stringify(
!actionsFilter ? action : actionsFilter(action.action, nextActionId - 1)
!actionSanitizer ? action : actionSanitizer(action.action, nextActionId - 1)
);
message.isExcess = isExcess;
message.nextActionId = nextActionId;
Expand Down Expand Up @@ -190,8 +190,8 @@ function init(options) {
if (sendOnError === 1) catchErrors();

if (options.actionCreators) actionCreators = () => getActionsArray(options.actionCreators);
statesFilter = options.statesFilter;
actionsFilter = options.actionsFilter;
stateSanitizer = options.stateSanitizer;
actionSanitizer = options.actionSanitizer;
}

function start() {
Expand Down

0 comments on commit b1f2ec9

Please sign in to comment.