-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathlogOnly.js
56 lines (46 loc) · 1.74 KB
/
logOnly.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"use strict";
var assign = require('./utils/assign');
var compose = require('redux').compose;
function enhancer() {
var config = arguments[0] || {};
config.features = { pause: true, export: true, test: true };
config.type = 'redux';
if (config.autoPause === undefined) config.autoPause = true;
if (config.latency === undefined) config.latency = 500;
return function(createStore) {
return function(reducer, preloadedState, enhancer) {
var store = createStore(reducer, preloadedState, enhancer);
var origDispatch = store.dispatch;
var devTools = window.__REDUX_DEVTOOLS_EXTENSION__.connect(config);
devTools.init(store.getState());
var dispatch = function(action) {
var r = origDispatch(action);
devTools.send(action, store.getState());
return r;
};
if (Object.assign) return Object.assign(store, { dispatch: dispatch });
return assign(store, 'dispatch', dispatch);
}
}
}
function composeWithEnhancer(config) {
return function () {
return compose(compose.apply(null, arguments), enhancer(config));
}
}
exports.__esModule = true;
exports.composeWithDevTools = function() {
if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
if (arguments.length === 0) return enhancer();
if (typeof arguments[0] === 'object') return composeWithEnhancer(arguments[0]);
return composeWithEnhancer().apply(null, arguments);
}
if (arguments.length === 0) return undefined;
if (typeof arguments[0] === 'object') return compose;
return compose.apply(null, arguments);
};
exports.devToolsEnhancer = (
typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__ ?
enhancer :
function() { return function(noop) { return noop; } }
);