You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.7 KiB

  1. "use strict";
  2. var assign = require('./utils/assign');
  3. var compose = require('redux').compose;
  4. function enhancer() {
  5. var config = arguments[0] || {};
  6. config.features = { pause: true, export: true, test: true };
  7. config.type = 'redux';
  8. if (config.autoPause === undefined) config.autoPause = true;
  9. if (config.latency === undefined) config.latency = 500;
  10. return function(createStore) {
  11. return function(reducer, preloadedState, enhancer) {
  12. var store = createStore(reducer, preloadedState, enhancer);
  13. var origDispatch = store.dispatch;
  14. var devTools = window.__REDUX_DEVTOOLS_EXTENSION__.connect(config);
  15. devTools.init(store.getState());
  16. var dispatch = function(action) {
  17. var r = origDispatch(action);
  18. devTools.send(action, store.getState());
  19. return r;
  20. };
  21. if (Object.assign) return Object.assign(store, { dispatch: dispatch });
  22. return assign(store, 'dispatch', dispatch);
  23. }
  24. }
  25. }
  26. function composeWithEnhancer(config) {
  27. return function () {
  28. return compose(compose.apply(null, arguments), enhancer(config));
  29. }
  30. }
  31. exports.__esModule = true;
  32. exports.composeWithDevTools = function() {
  33. if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
  34. if (arguments.length === 0) return enhancer();
  35. if (typeof arguments[0] === 'object') return composeWithEnhancer(arguments[0]);
  36. return composeWithEnhancer().apply(null, arguments);
  37. }
  38. if (arguments.length === 0) return undefined;
  39. if (typeof arguments[0] === 'object') return compose;
  40. return compose.apply(null, arguments);
  41. };
  42. exports.devToolsEnhancer = (
  43. typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__ ?
  44. enhancer :
  45. function() { return function(noop) { return noop; } }
  46. );