Skip to content

Commit

Permalink
RN: Delete NativeEventEmitter Options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Feb 2, 2021
1 parent d54b286 commit f5f4787
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions Libraries/EventEmitter/NativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -38,15 +30,9 @@ export default class NativeEventEmitter<
EventDefinitions: {...},
> extends EventEmitter<EventDefinitions> {
_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;
Expand All @@ -58,7 +44,7 @@ export default class NativeEventEmitter<
listener: (...$ElementType<EventDefinitions, K>) => mixed,
context: $FlowFixMe,
): EmitterSubscription<EventDefinitions, K> {
if (this._nativeModule != null && !this._disableCallsIntoModule) {
if (this._nativeModule != null) {
this._nativeModule.addListener(eventType);
}
return super.addListener(eventType, listener, context);
Expand All @@ -67,7 +53,7 @@ export default class NativeEventEmitter<
removeAllListeners<K: $Keys<EventDefinitions>>(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);
Expand All @@ -76,7 +62,7 @@ export default class NativeEventEmitter<
removeSubscription<K: $Keys<EventDefinitions>>(
subscription: EmitterSubscription<EventDefinitions, K>,
): void {
if (this._nativeModule != null && !this._disableCallsIntoModule) {
if (this._nativeModule != null) {
this._nativeModule.removeListeners(1);
}
super.removeSubscription(subscription);
Expand Down

0 comments on commit f5f4787

Please sign in to comment.