store.js 859 B

12345678910111213141516171819202122232425262728293031323334
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const { combineReducers } = require("devtools/client/shared/vendor/redux");
  6. const createStore = require("devtools/client/shared/redux/create-store");
  7. const reducers = require("./reducers");
  8. const flags = require("devtools/shared/flags");
  9. module.exports = function () {
  10. let shouldLog = false;
  11. let history;
  12. // If testing, store the action history in an array
  13. // we'll later attach to the store
  14. if (flags.testing) {
  15. history = [];
  16. shouldLog = true;
  17. }
  18. let store = createStore({
  19. log: shouldLog,
  20. history
  21. })(combineReducers(reducers), {});
  22. if (history) {
  23. store.history = history;
  24. }
  25. return store;
  26. };