From f5f47879b8320a9934914cb8ce7a72269840a83a Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Mon, 1 Feb 2021 17:47:09 -0800 Subject: [PATCH] RN: Delete `NativeEventEmitter` Options Summary: Removes the `options` argument in the `NativeEventEmitter` constructor. It was only being used for an experimental flag that is no longer necessary. Changelog: [General][Removed] - Removed second optional argument of `NativeEventEmitter` constructor Reviewed By: RSNara Differential Revision: D26138239 fbshipit-source-id: 0481ce44f0464668e3a6e7ffaf079d17c87afd42 --- Libraries/EventEmitter/NativeEventEmitter.js | 22 ++++---------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Libraries/EventEmitter/NativeEventEmitter.js b/Libraries/EventEmitter/NativeEventEmitter.js index 328a02300c4d7c..a5ba4f108115f6 100644 --- a/Libraries/EventEmitter/NativeEventEmitter.js +++ b/Libraries/EventEmitter/NativeEventEmitter.js @@ -22,14 +22,6 @@ type NativeModule = { ... }; -type NativeEventEmitterOptions = $ReadOnly<{| - __SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: boolean, -|}>; - -const DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS = { - __SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: false, -}; - /** * Abstract base class for implementing event-emitting modules. This implements * a subset of the standard EventEmitter node module API. @@ -38,15 +30,9 @@ export default class NativeEventEmitter< EventDefinitions: {...}, > extends EventEmitter { _nativeModule: ?NativeModule; - _disableCallsIntoModule: boolean; - constructor( - nativeModule: ?NativeModule, - options: NativeEventEmitterOptions = DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS, - ) { + constructor(nativeModule: ?NativeModule) { super(RCTDeviceEventEmitter.sharedSubscriber); - this._disableCallsIntoModule = - options.__SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; if (Platform.OS === 'ios') { invariant(nativeModule, 'Native module cannot be null.'); this._nativeModule = nativeModule; @@ -58,7 +44,7 @@ export default class NativeEventEmitter< listener: (...$ElementType) => mixed, context: $FlowFixMe, ): EmitterSubscription { - if (this._nativeModule != null && !this._disableCallsIntoModule) { + if (this._nativeModule != null) { this._nativeModule.addListener(eventType); } return super.addListener(eventType, listener, context); @@ -67,7 +53,7 @@ export default class NativeEventEmitter< removeAllListeners>(eventType: ?K): void { invariant(eventType, 'eventType argument is required.'); const count = this.listenerCount(eventType); - if (this._nativeModule != null && !this._disableCallsIntoModule) { + if (this._nativeModule != null) { this._nativeModule.removeListeners(count); } super.removeAllListeners(eventType); @@ -76,7 +62,7 @@ export default class NativeEventEmitter< removeSubscription>( subscription: EmitterSubscription, ): void { - if (this._nativeModule != null && !this._disableCallsIntoModule) { + if (this._nativeModule != null) { this._nativeModule.removeListeners(1); } super.removeSubscription(subscription);