UNPKG

electron-redux-devtools

Version:
57 lines (46 loc) 1.78 kB
"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; } } );