simple-prefs.js 793 B

1234567891011121314151617181920212223242526
  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. module.metadata = {
  6. "stability": "experimental"
  7. };
  8. const { emit, off } = require("./event/core");
  9. const { PrefsTarget } = require("./preferences/event-target");
  10. const { preferencesBranch, id } = require("./self");
  11. const { on } = require("./system/events");
  12. const ADDON_BRANCH = "extensions." + preferencesBranch + ".";
  13. const BUTTON_PRESSED = id + "-cmdPressed";
  14. const target = PrefsTarget({ branchName: ADDON_BRANCH });
  15. // Listen to clicks on buttons
  16. function buttonClick({ data }) {
  17. emit(target, data);
  18. }
  19. on(BUTTON_PRESSED, buttonClick);
  20. module.exports = target;