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:
Родитель
d54b286b97
Коммит
f5f47879b8
|
@ -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<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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче