UNPKG

6.68 kBMarkdownView Raw
1Remote Redux DevTools
2=====================
3
4![Demo](demo.gif)
5
6Use [Redux DevTools](https://github.com/gaearon/redux-devtools) remotely for React Native, hybrid, desktop and server side Redux apps.
7
8### Installation
9
10```
11npm install --save-dev remote-redux-devtools
12```
13
14### Usage
15
16Just [add our store enhancer to your store](https://github.com/zalmoxisus/remote-redux-devtools/commit/eb18fc49e1f083a2330939af52da349b862f8df1):
17
18##### `store/configureStore.js`
19
20```js
21import { createStore, applyMiddleware, compose } from 'redux';
22import thunk from 'redux-thunk';
23import devTools from 'remote-redux-devtools';
24import reducer from '../reducers';
25
26export default function configureStore(initialState) {
27 const enhancer = compose(
28 applyMiddleware(thunk),
29 devTools()
30 );
31 // Note: passing enhancer as last argument requires redux@>=3.1.0
32 const store = createStore(reducer, initialState, enhancer);
33 // If you have other enhancers & middlewares
34 // update the store after creating / changing to allow devTools to use them
35 devTools.updateStore(store);
36 return store;
37}
38```
39
40#### Important
41
42In order not to allow it in production by default, the enhancer will have effect only when `process.env.NODE_ENV === 'development'`. In case you don't set `NODE_ENV` or want to use it in production, set `realtime` parameter to `true`:
43
44```js
45const enhancer = compose(
46 applyMiddleware(thunk),
47 devTools({ realtime: true })
48);
49```
50
51### Monitoring
52
53Use one of our monitor apps to inspect and dispatch actions:
54* [web](http://remotedev.io/local)
55* [redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension) - Click "Remote" button (or press [`Cmd+Ctrl+Arrow up`](https://github.com/zalmoxisus/redux-devtools-extension#keyboard-shortcuts)) to open remote monitoring.
56* [react-native-debugger](https://github.com/jhen0409/react-native-debugger) - Electron app, which already includes `remotedev-server`, `remotedev-app` and even React DevTools.
57* [chrome app](https://chrome.google.com/webstore/detail/remotedev/faicmgpfiaijcedapokpbdejaodbelph).
58* [remote-redux-devtools-on-debugger](https://github.com/jhen0409/remote-redux-devtools-on-debugger) - Used in React Native debugger as a dock monitor.
59* [atom-redux-devtools](https://github.com/zalmoxisus/atom-redux-devtools) - Used in Atom editor.
60* [redux-dispatch-cli](https://github.com/jhen0409/redux-dispatch-cli) - A CLI tool for Redux remote dispatch.
61
62Use [remotedev-app](https://github.com/zalmoxisus/remotedev-app) to create your own monitor app.
63
64### Communicate via local server
65
66In order to make it simple to use, by default, the module and the monitor app communicate via [remotedev.io](http://remotedev.io) server. Use [remotedev-server](https://github.com/zalmoxisus/remotedev-server) cli to run it locally in order to make the connection faster and not to require an internet connection.
67You can import it in your `server.js` script and start remotedev server together with your development server:
68```js
69var remotedev = require('remotedev-server');
70remotedev({ hostname: 'localhost', port: 8000 });
71```
72See [remotedev-server](https://github.com/zalmoxisus/remotedev-server) repository for more details.
73For React Native you can use [react-native-debugger](https://github.com/jhen0409/react-native-debugger) or [remote-redux-devtools-on-debugger](https://github.com/jhen0409/remote-redux-devtools-on-debugger), which already include `remotedev-server`.
74
75
76### Parameters
77
78Name | Description
79------------- | -------------
80`name` | *String* representing the instance name to be shown on the remote monitor.
81`realtime` | *Boolean* specifies whether to allow remote monitoring. By default is `process.env.NODE_ENV === 'development'`.
82`hostname` | *String* used to specify host for [`remotedev-server`](https://github.com/zalmoxisus/remotedev-server). If `port` is specified, default value is `localhost`.
83`port` | *Number* used to specify host's port for [`remotedev-server`](https://github.com/zalmoxisus/remotedev-server).
84`secure` | *Boolean* specifies whether to use `https` protocol for [`remotedev-server`](https://github.com/zalmoxisus/remotedev-server).
85`filters` | *Map of arrays* named `whitelist` or `blacklist` to filter action types.
86`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`.
87`startOn` | *String* or *Array of strings* indicating an action or a list of actions, which should start remote monitoring (when `realtime` is `false`).
88`stopOn` | *String* or *Array of strings* indicating an action or a list of actions, which should stop remote monitoring.
89`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.
90`sendOnError` | *Numeric* code: `0` - disabled (default), `1` - send all uncaught exception messages, `2` - send only reducers error messages.
91`sendTo` | *String* url of the monitor to send the history when `sendOn` is triggered. By default is `${secure ? 'https' : 'http'}://${hostname}:${port}`.
92`actionCreators` | *Array* or *Object* of action creators to dispatch remotely. See [the example](https://github.com/zalmoxisus/remote-redux-devtools/commit/b54652930dfd4e057991df8471c343957fd7bff7).
93`id` | *String* to identify the instance when sending the history triggered by `sendOn`. You can use, for example, user id here, to know who sent the data.
94
95All parameters are optional. You have to provide at least `port` property to use `localhost` instead of `remotedev.io` server.
96
97Example:
98```js
99export default function configureStore(initialState) {
100 // Note: passing enhancer as last argument requires redux@>=3.1.0
101 const store = createStore(
102 rootReducer,
103 initialState,
104 devTools({
105 name: 'Android app', realtime: true,
106 hostname: 'localhost', port: 8000,
107 maxAge: 30, filters: { blacklist: ['EFFECT_RESOLVED'] }
108 })
109 );
110 // If you have other enhancers & middlewares
111 // update the store after creating / changing to allow devTools to use them
112 devTools.updateStore(store);
113 return store;
114}
115```
116
117### Demo
118- [Toggle monitoring](http://zalmoxisus.github.io/monitoring/)
119
120### Examples
121- [Web](https://github.com/zalmoxisus/remote-redux-devtools/tree/master/examples)
122- [React Native](https://github.com/chentsulin/react-native-counter-ios-android)
123
124### License
125
126MIT