Skip to content

Commit

Permalink
RN: Delete Linking.removeEventListener
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Feb 3, 2021
1 parent 07e4953 commit 6d1aca8
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions Libraries/Linking/Linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -41,20 +42,8 @@ class Linking extends NativeEventEmitter<LinkingEventDefinitions> {
eventType: K,
listener: (...$ElementType<LinkingEventDefinitions, K>) => 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<K: $Keys<LinkingEventDefinitions>>(
eventType: K,
listener: (...$ElementType<LinkingEventDefinitions, K>) => mixed,
): void {
this.removeListener(eventType, listener);
): EventSubscription {
return this.addListener(eventType, listener);
}

/**
Expand Down

0 comments on commit 6d1aca8

Please sign in to comment.