Browse Source

@uppy/core: move event emitter to private properties (#3042)

Antoine du Hamel 3 years ago
parent
commit
e0b1c04809
1 changed files with 13 additions and 8 deletions
  1. 13 8
      packages/@uppy/core/src/index.js

+ 13 - 8
packages/@uppy/core/src/index.js

@@ -36,6 +36,8 @@ class Uppy {
 
   #storeUnsubscribe
 
+  #emitter = ee()
+
   /**
    * Instantiate Uppy
    *
@@ -178,12 +180,6 @@ class Uppy {
     this.retryUpload = this.retryUpload.bind(this)
     this.upload = this.upload.bind(this)
 
-    this.emitter = ee()
-    this.on = this.on.bind(this)
-    this.off = this.off.bind(this)
-    this.once = this.emitter.once.bind(this.emitter)
-    this.emit = this.emitter.emit.bind(this.emitter)
-
     this.preProcessors = []
     this.uploaders = []
     this.postProcessors = []
@@ -222,13 +218,22 @@ class Uppy {
     this.#addListeners()
   }
 
+  emit (event, ...args) {
+    this.#emitter.emit(event, ...args)
+  }
+
   on (event, callback) {
-    this.emitter.on(event, callback)
+    this.#emitter.on(event, callback)
+    return this
+  }
+
+  once (event, callback) {
+    this.#emitter.once(event, callback)
     return this
   }
 
   off (event, callback) {
-    this.emitter.off(event, callback)
+    this.#emitter.off(event, callback)
     return this
   }