From 6d1aca806cee86ad76de771ed3a1cc62982ebcd7 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Tue, 2 Feb 2021 19:33:30 -0800 Subject: [PATCH] RN: Delete `Linking.removeEventListener` Summary: Deletes `Linking.removeEventListener` in favor of returning the `EventSubscription` returned by `NativeEventEmitter.addListener`. Changelog: [General][Added] - `Linking.addEventListener` now returns a subscription with a `remove()` method. [General][Removed] - Removed `Linking.removeEventListener`. Instead, call `remove()` on the subscription returned by `Linking.addEventListener`. Reviewed By: rubennorte, wtfil Differential Revision: D26155896 fbshipit-source-id: 1176ec6eae1c0fff2d68acf5411a18da530b212a --- Libraries/Linking/Linking.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Libraries/Linking/Linking.js b/Libraries/Linking/Linking.js index d2de3d634b54c7..6acc9be2bb3883 100644 --- a/Libraries/Linking/Linking.js +++ b/Libraries/Linking/Linking.js @@ -8,6 +8,7 @@ * @flow strict-local */ +import {type EventSubscription} from '../vendor/emitter/EventEmitter'; import NativeEventEmitter from '../EventEmitter/NativeEventEmitter'; import InteractionManager from '../Interaction/InteractionManager'; import Platform from '../Utilities/Platform'; @@ -41,20 +42,8 @@ class Linking extends NativeEventEmitter { eventType: K, listener: (...$ElementType) => mixed, context: $FlowFixMe, - ): void { - this.addListener(eventType, listener); - } - - /** - * Remove a handler by passing the `url` event type and the handler. - * - * See https://reactnative.dev/docs/linking.html#removeeventlistener - */ - removeEventListener>( - eventType: K, - listener: (...$ElementType) => mixed, - ): void { - this.removeListener(eventType, listener); + ): EventSubscription { + return this.addListener(eventType, listener); } /**