Skip to content

Commit a87a6ee

Browse files
committed
Describe getMonitor api
Related to #140 & #145.
1 parent 352f079 commit a87a6ee

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/API/Arguments.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@
5151
statesFilter: (state) => state.data ? { ...state, data: '<<LONG_BLOB>>' } : state)
5252
}));
5353
```
54+
- **getMonitor** (*function*) - return monitor object with the following properties:
55+
- **start** (*function*) - starts monitoring (relaying logs to the monitor).
56+
- **stop** (*function*) - stop monitoring (the monitor will not get new changes till you `start` it again with the function above).
57+
- **update** (*function*) - update state history. Usually you want to use it when stopped monitoring (with the function above) and want to update the logs explicitly (useful for apps which dispatch actions too frequently).
58+
- **isHotReloaded** (*function*) - return `true` if reducers just got hot reloaded (useful for dealing with side effects, which didn't get hot-reloaded).
59+
- **isMonitorAction** (*function*) - return `true` if the last action was dispatched by the monitor (was: 'TOGGLE_ACTION', 'SWEEP', 'SET_ACTIONS_ACTIVE', 'IMPORT_STATE').
60+
- **isTimeTraveling** (*function*) - return `true` if the state was set by moving back and forth (the last action was dispatched by the monitor was 'JUMP_TO_STATE'). Usually you want to use it to skip side effects.
61+
Example of usage:
62+
63+
```js
64+
export let isMonitorAction;
65+
export default function configureStore(initialState) {
66+
return createStore(reducer, initialState,
67+
window.devToolsExtension && window.devToolsExtension({
68+
getMonitor: (monitor) => { isMonitorAction = monitor.isMonitorAction; }
69+
}) : f => f
70+
);
71+
}
72+
```
73+
Then import it, for example, like [here](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/examples/counter/components/Counter.js).
5474
5575
### `window.devToolsExtension(reducer, [preloadedState, config])`
5676
> Note: This is not intended to replace Redux' `createStore`. Use this approach only when you want to inspect changes outside of Redux or when not using Redux inside your application.

0 commit comments

Comments
 (0)