addon-sdk/source/lib/sdk/panel/events.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:f8235ec7d6b6
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
5 "use strict";
6
7 // This module basically translates system/events to a SDK standard events
8 // so that `map`, `filter` and other utilities could be used with them.
9
10 module.metadata = {
11 "stability": "experimental"
12 };
13
14 const events = require("../system/events");
15 const { emit } = require("../event/core");
16
17 let channel = {};
18
19 function forward({ subject, type, data })
20 emit(channel, "data", { target: subject, type: type, data: data });
21
22 ["popupshowing", "popuphiding", "popupshown", "popuphidden",
23 "document-element-inserted", "DOMContentLoaded", "load"
24 ].forEach(function(type) events.on(type, forward));
25
26 exports.events = channel;

mercurial