| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @fileOverview This component manages listeners and calls them to distributes | 21 * @fileOverview This component manages listeners and calls them to distributes |
| 22 * messages about filter changes. | 22 * messages about filter changes. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 const {EventEmitter} = require("./events"); | 25 import {EventEmitter} from "./events"; |
| 26 const {desc} = require("./coreUtils"); | 26 import {desc} from "./coreUtils"; |
| 27 | 27 |
| 28 const CATCH_ALL = "__all"; | 28 const CATCH_ALL = "__all"; |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * @callback FilterNotifierCatchAllListener | 31 * @callback FilterNotifierCatchAllListener |
| 32 * @param {string} action | 32 * @param {string} action |
| 33 * @param {Subscription|Filter} item | 33 * @param {Subscription|Filter} item |
| 34 * @param {...*} additionalInfo | 34 * @param {...*} additionalInfo |
| 35 */ | 35 */ |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * This class allows registering and triggering listeners for filter events. | 38 * This class allows registering and triggering listeners for filter events. |
| 39 * @class | 39 * @class |
| 40 */ | 40 */ |
| 41 exports.FilterNotifier = Object.create(new EventEmitter(), desc({ | 41 export let FilterNotifier = Object.create(new EventEmitter(), desc({ |
| 42 /** | 42 /** |
| 43 * Adds a listener | 43 * Adds a listener |
| 44 * | 44 * |
| 45 * @deprecated use FilterNotifier.on(action, callback) | 45 * @deprecated use FilterNotifier.on(action, callback) |
| 46 * @param {FilterNotifierCatchAllListener} listener | 46 * @param {FilterNotifierCatchAllListener} listener |
| 47 */ | 47 */ |
| 48 addListener(listener) | 48 addListener(listener) |
| 49 { | 49 { |
| 50 let listeners = this._listeners[CATCH_ALL]; | 50 let listeners = this._listeners[CATCH_ALL]; |
| 51 if (!listeners || listeners.indexOf(listener) == -1) | 51 if (!listeners || listeners.indexOf(listener) == -1) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 77 * @param {*} param2 | 77 * @param {*} param2 |
| 78 * @param {*} param3 | 78 * @param {*} param3 |
| 79 * @deprecated use FilterNotifier.emit(action) | 79 * @deprecated use FilterNotifier.emit(action) |
| 80 */ | 80 */ |
| 81 triggerListeners(action, item, param1, param2, param3) | 81 triggerListeners(action, item, param1, param2, param3) |
| 82 { | 82 { |
| 83 this.emit(action, item, param1, param2, param3); | 83 this.emit(action, item, param1, param2, param3); |
| 84 this.emit(CATCH_ALL, action, item, param1, param2, param3); | 84 this.emit(CATCH_ALL, action, item, param1, param2, param3); |
| 85 } | 85 } |
| 86 })); | 86 })); |
| OLD | NEW |