remote-redux-devtools
Advanced tools
Comparing version 0.5.0-alpha to 0.5.0
@@ -9,4 +9,4 @@ 'use strict'; | ||
exports.default = devTools; | ||
exports.preDevTools = preDevTools; | ||
exports.default = devToolsEnhancer; | ||
exports.preEnhancer = preEnhancer; | ||
exports.composeWithDevTools = composeWithDevTools; | ||
@@ -56,2 +56,3 @@ | ||
var locked = void 0; | ||
var paused = void 0; | ||
var actionCreators = void 0; | ||
@@ -250,6 +251,2 @@ var stateSanitizer = void 0; | ||
if (checkForReducerErrors(liftedState)) return; | ||
if (lastAction === 'LOCK_CHANGES') { | ||
if (liftedState.dropNewActions === locked) return; | ||
locked = liftedState.dropNewActions; | ||
} | ||
@@ -263,2 +260,10 @@ if (lastAction === 'PERFORM_ACTION') { | ||
if (lastAction === 'JUMP_TO_STATE') return; | ||
if (lastAction === 'PAUSE_RECORDING') { | ||
paused = liftedState.isPaused; | ||
} else if (lastAction === 'LOCK_CHANGES') { | ||
locked = liftedState.isLocked; | ||
} | ||
if (paused || locked) { | ||
if (lastAction) lastAction = undefined;else return; | ||
} | ||
relay('STATE', (0, _filters.filterStagedActions)(liftedState, filters)); | ||
@@ -268,3 +273,3 @@ } | ||
function devTools() { | ||
function devToolsEnhancer() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -286,3 +291,6 @@ | ||
shouldCatchErrors: !!sendOnError, | ||
shouldHotReload: options.shouldHotReload | ||
shouldHotReload: options.shouldHotReload, | ||
shouldRecordChanges: options.shouldRecordChanges, | ||
shouldStartLocked: options.shouldStartLocked, | ||
pauseActionType: options.pauseActionType || '@@PAUSED' | ||
})(reducer, initialState); | ||
@@ -299,3 +307,3 @@ | ||
function preDevTools(createStore) { | ||
function preEnhancer(createStore) { | ||
return function (reducer, preloadedState, enhancer) { | ||
@@ -311,26 +319,29 @@ store = createStore(reducer, preloadedState, enhancer); | ||
devTools.updateStore = function (newStore) { | ||
devToolsEnhancer.updateStore = function (newStore) { | ||
console.warn('devTools.updateStore is deprecated use composeWithDevTools instead: ' + 'https://github.com/zalmoxisus/remote-redux-devtools#use-devtools-compose-helper'); | ||
store = newStore; | ||
}; | ||
function composeWithDevTools() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
var compose = function compose(options) { | ||
return function () { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
if (funcs.length === 0) { | ||
return devTools; | ||
} | ||
if (funcs.length === 1 && _typeof(funcs[0]) === 'object') { | ||
return devTools(funcs[0]); | ||
} | ||
return function (options) { | ||
return function () { | ||
return [preDevTools].concat(funcs).reduceRight(function (composed, f) { | ||
return [preEnhancer].concat(funcs).reduceRight(function (composed, f) { | ||
return f(composed); | ||
}, devTools(options).apply(undefined, arguments)); | ||
}, devToolsEnhancer(options).apply(undefined, arguments)); | ||
}; | ||
}; | ||
}; | ||
function composeWithDevTools() { | ||
if (arguments.length === 0) { | ||
return devToolsEnhancer(); | ||
} | ||
if (arguments.length === 1 && _typeof(arguments.length <= 0 ? undefined : arguments[0]) === 'object') { | ||
return compose(arguments.length <= 0 ? undefined : arguments[0]); | ||
} | ||
return compose({}).apply(undefined, arguments); | ||
} |
{ | ||
"name": "remote-redux-devtools", | ||
"version": "0.5.0-alpha", | ||
"version": "0.5.0", | ||
"description": "Relay Redux actions to remote Redux DevTools.", | ||
@@ -57,3 +57,3 @@ "main": "lib/index.js", | ||
"querystring": "^0.2.0", | ||
"redux-devtools-instrument": "^1.2.0", | ||
"redux-devtools-instrument": "^1.3.1", | ||
"remotedev-utils": "0.0.5", | ||
@@ -60,0 +60,0 @@ "socketcluster-client": "4.3.19" |
@@ -16,26 +16,54 @@ Remote Redux DevTools | ||
Just [add our store enhancer to your store](https://github.com/zalmoxisus/remote-redux-devtools/commit/eb18fc49e1f083a2330939af52da349b862f8df1): | ||
There are 2 ways of usage depending if you're using other store enhancers (middlewares) or not. | ||
##### `store/configureStore.js` | ||
#### Add DevTools enhancer to your store | ||
```js | ||
import { createStore, applyMiddleware, compose } from 'redux'; | ||
import thunk from 'redux-thunk'; | ||
import devTools from 'remote-redux-devtools'; | ||
import reducer from '../reducers'; | ||
If you have a basic [store](http://redux.js.org/docs/api/createStore.html) as described in the official [redux-docs](http://redux.js.org/index.html), simply replace: | ||
```javascript | ||
import { createStore } from 'redux'; | ||
const store = createStore(reducer); | ||
``` | ||
with | ||
```javascript | ||
import { createStore } from 'redux'; | ||
import devToolsEnhancer from 'remote-redux-devtools'; | ||
const store = createStore(reducer, devToolsEnhancer()); | ||
// or const store = createStore(reducer, preloadedState, devToolsEnhancer()); | ||
``` | ||
> Note: passing enhancer as last argument requires redux@>=3.1.0 | ||
export default function configureStore(initialState) { | ||
const enhancer = compose( | ||
applyMiddleware(thunk), | ||
devTools() | ||
); | ||
// Note: passing enhancer as last argument requires redux@>=3.1.0 | ||
const store = createStore(reducer, initialState, enhancer); | ||
// If you have other enhancers & middlewares | ||
// update the store after creating / changing to allow devTools to use them | ||
devTools.updateStore(store); | ||
return store; | ||
} | ||
``` | ||
#### Use DevTools compose helper | ||
If you setup your store with [middleware and enhancers](http://redux.js.org/docs/api/applyMiddleware.html), change this: | ||
```javascript | ||
import { createStore, applyMiddleware, compose } from 'redux'; | ||
const store = createStore(reducer, preloadedState, compose( | ||
applyMiddleware(...middleware), | ||
// other store enhancers if any | ||
)); | ||
``` | ||
to: | ||
```javascript | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import { composeWithDevTools } from 'remote-redux-devtools'; | ||
const store = composeWithDevTools(reducer, /* preloadedState, */ composeWithDevTools( | ||
applyMiddleware(...middleware), | ||
// other store enhancers if any | ||
)); | ||
``` | ||
or with devTools' options: | ||
```javascript | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import { composeWithDevTools } from 'remote-redux-devtools'; | ||
const composeEnhancers = composeWithDevTools({ realtime: true, port: 8000 }); | ||
const store = composeWithDevTools(reducer, /* preloadedState, */ composeEnhancers( | ||
applyMiddleware(...middleware), | ||
// other store enhancers if any | ||
)); | ||
``` | ||
#### Important | ||
@@ -45,8 +73,5 @@ | ||
```js | ||
const enhancer = compose( | ||
applyMiddleware(thunk), | ||
devTools({ realtime: true }) | ||
); | ||
``` | ||
```js | ||
const store = createStore(reducer, devToolsEnhancer({ realtime: true })); | ||
``` | ||
@@ -97,3 +122,5 @@ ### Monitoring | ||
`actionCreators` | *Array* or *Object* of action creators to dispatch remotely. See [the example](https://github.com/zalmoxisus/remote-redux-devtools/commit/b54652930dfd4e057991df8471c343957fd7bff7). | ||
`shouldHotReload` | *Boolean* - if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Default to `true`. | ||
`shouldHotReload` | *Boolean* - if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Default to `true`. | ||
`shouldRecordChanges`| *Boolean* - if specified as `false`, it will not record the changes till clicked on "Start recording" button on the monitor app. Default is `true`. | ||
`shouldStartLocked` | *Boolean* - if specified as `true`, it will not allow any non-monitor actions to be dispatched till `lockChanges(false)` is dispatched. Default is `false`. | ||
`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. | ||
@@ -105,8 +132,7 @@ | ||
```js | ||
export default function configureStore(initialState) { | ||
// Note: passing enhancer as last argument requires redux@>=3.1.0 | ||
export default function configureStore(preloadedState) { | ||
const store = createStore( | ||
rootReducer, | ||
initialState, | ||
devTools({ | ||
reducer, | ||
preloadedState, | ||
devToolsEnhancer({ | ||
name: 'Android app', realtime: true, | ||
@@ -122,5 +148,2 @@ hostname: 'localhost', port: 8000, | ||
); | ||
// If you have other enhancers & middlewares | ||
// update the store after creating / changing to allow devTools to use them | ||
devTools.updateStore(store); | ||
return store; | ||
@@ -127,0 +150,0 @@ } |
24147
334
158