summaryrefslogtreecommitdiffstats
path: root/services/cloudsync/CloudSyncEventSource.jsm
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-17 20:22:59 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-17 20:22:59 +0200
commit3eb4310cd889e6c8d22c27f0326273acf0a3e8bf (patch)
tree508827a64a5ad5c2d465535afea68eee39775a11 /services/cloudsync/CloudSyncEventSource.jsm
parent07381c3edad8ec24b5d820ec0592e0cafa7d73fa (diff)
parent1e868fadf94935bcb4a49ea5eec776d84fe2d1e7 (diff)
downloadUXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.gz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.lz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.tar.xz
UXP-3eb4310cd889e6c8d22c27f0326273acf0a3e8bf.zip
Merge branch 'Sync-weave'
Diffstat (limited to 'services/cloudsync/CloudSyncEventSource.jsm')
-rw-r--r--services/cloudsync/CloudSyncEventSource.jsm65
1 files changed, 0 insertions, 65 deletions
diff --git a/services/cloudsync/CloudSyncEventSource.jsm b/services/cloudsync/CloudSyncEventSource.jsm
deleted file mode 100644
index edb9c426b..000000000
--- a/services/cloudsync/CloudSyncEventSource.jsm
+++ /dev/null
@@ -1,65 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-this.EXPORTED_SYMBOLS = ["EventSource"];
-
-Components.utils.import("resource://services-common/utils.js");
-
-var EventSource = function (types, suspendFunc, resumeFunc) {
- this.listeners = new Map();
- for (let type of types) {
- this.listeners.set(type, new Set());
- }
-
- this.suspend = suspendFunc || function () {};
- this.resume = resumeFunc || function () {};
-
- this.addEventListener = this.addEventListener.bind(this);
- this.removeEventListener = this.removeEventListener.bind(this);
-};
-
-EventSource.prototype = {
- addEventListener: function (type, listener) {
- if (!this.listeners.has(type)) {
- return;
- }
- this.listeners.get(type).add(listener);
- this.resume();
- },
-
- removeEventListener: function (type, listener) {
- if (!this.listeners.has(type)) {
- return;
- }
- this.listeners.get(type).delete(listener);
- if (!this.hasListeners()) {
- this.suspend();
- }
- },
-
- hasListeners: function () {
- for (let l of this.listeners.values()) {
- if (l.size > 0) {
- return true;
- }
- }
- return false;
- },
-
- emit: function (type, arg) {
- if (!this.listeners.has(type)) {
- return;
- }
- CommonUtils.nextTick(
- function () {
- for (let listener of this.listeners.get(type)) {
- listener.call(undefined, arg);
- }
- },
- this
- );
- },
-};
-
-this.EventSource = EventSource;