diff --git a/Libraries/EventEmitter/NativeEventEmitter.js b/Libraries/EventEmitter/NativeEventEmitter.js index 328a02300c..a5ba4f1081 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);