Prechádzať zdrojové kódy

Alias "removeListener" as "off" in Redis emitter (#4647)

This makes the Redis emitter API consistent with the Node emitter API and the documentation.
Elliot Dickison 1 rok pred
rodič
commit
90d137b67e

+ 11 - 0
packages/@uppy/companion/src/server/emitter/redis-emitter.js

@@ -93,6 +93,16 @@ module.exports = (redisClient, redisPubSubScope) => {
     return addListener(eventName, handler)
   }
 
+  /**
+   * Remove an event listener
+   *
+   * @param {string} eventName name of the event
+   * @param {any} handler the handler of the event
+   */
+  function off (eventName, handler) {
+    return removeListener(eventName, handler)
+  }
+
   /**
    * Add an event listener (will be triggered at most once)
    *
@@ -130,6 +140,7 @@ module.exports = (redisClient, redisPubSubScope) => {
 
   return {
     on,
+    off,
     once,
     emit,
     removeListener,