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
This commit is contained in:
Tim Yung 2021-02-01 17:47:09 -08:00 коммит произвёл Facebook GitHub Bot
Родитель d54b286b97
Коммит f5f47879b8
1 изменённых файлов: 4 добавлений и 18 удалений

Просмотреть файл

@ -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 * Abstract base class for implementing event-emitting modules. This implements
* a subset of the standard EventEmitter node module API. * a subset of the standard EventEmitter node module API.
@ -38,15 +30,9 @@ export default class NativeEventEmitter<
EventDefinitions: {...}, EventDefinitions: {...},
> extends EventEmitter<EventDefinitions> { > extends EventEmitter<EventDefinitions> {
_nativeModule: ?NativeModule; _nativeModule: ?NativeModule;
_disableCallsIntoModule: boolean;
constructor( constructor(nativeModule: ?NativeModule) {
nativeModule: ?NativeModule,
options: NativeEventEmitterOptions = DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS,
) {
super(RCTDeviceEventEmitter.sharedSubscriber); super(RCTDeviceEventEmitter.sharedSubscriber);
this._disableCallsIntoModule =
options.__SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
if (Platform.OS === 'ios') { if (Platform.OS === 'ios') {
invariant(nativeModule, 'Native module cannot be null.'); invariant(nativeModule, 'Native module cannot be null.');
this._nativeModule = nativeModule; this._nativeModule = nativeModule;
@ -58,7 +44,7 @@ export default class NativeEventEmitter<
listener: (...$ElementType<EventDefinitions, K>) => mixed, listener: (...$ElementType<EventDefinitions, K>) => mixed,
context: $FlowFixMe, context: $FlowFixMe,
): EmitterSubscription<EventDefinitions, K> { ): EmitterSubscription<EventDefinitions, K> {
if (this._nativeModule != null && !this._disableCallsIntoModule) { if (this._nativeModule != null) {
this._nativeModule.addListener(eventType); this._nativeModule.addListener(eventType);
} }
return super.addListener(eventType, listener, context); return super.addListener(eventType, listener, context);
@ -67,7 +53,7 @@ export default class NativeEventEmitter<
removeAllListeners<K: $Keys<EventDefinitions>>(eventType: ?K): void { removeAllListeners<K: $Keys<EventDefinitions>>(eventType: ?K): void {
invariant(eventType, 'eventType argument is required.'); invariant(eventType, 'eventType argument is required.');
const count = this.listenerCount(eventType); const count = this.listenerCount(eventType);
if (this._nativeModule != null && !this._disableCallsIntoModule) { if (this._nativeModule != null) {
this._nativeModule.removeListeners(count); this._nativeModule.removeListeners(count);
} }
super.removeAllListeners(eventType); super.removeAllListeners(eventType);
@ -76,7 +62,7 @@ export default class NativeEventEmitter<
removeSubscription<K: $Keys<EventDefinitions>>( removeSubscription<K: $Keys<EventDefinitions>>(
subscription: EmitterSubscription<EventDefinitions, K>, subscription: EmitterSubscription<EventDefinitions, K>,
): void { ): void {
if (this._nativeModule != null && !this._disableCallsIntoModule) { if (this._nativeModule != null) {
this._nativeModule.removeListeners(1); this._nativeModule.removeListeners(1);
} }
super.removeSubscription(subscription); super.removeSubscription(subscription);