mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
EventEmitter: Cleanup Redundant Internal Types
Summary: Cleans up some minor redundant internal types in `_EventEmitter.js`. Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D27712301 fbshipit-source-id: e6affcb7948e0f47a1775b74b12f59ec2a6abddb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
14f7a2b707
commit
62934e555d
+3
-21
@@ -12,25 +12,11 @@
|
||||
const invariant = require('invariant');
|
||||
|
||||
import EmitterSubscription from './_EmitterSubscription';
|
||||
import {type EventSubscription} from './EventSubscription';
|
||||
import EventSubscriptionVendor from './_EventSubscriptionVendor';
|
||||
|
||||
const sparseFilterPredicate = () => true;
|
||||
|
||||
export interface IEventEmitter<EventDefinitions: {...}> {
|
||||
addListener<K: $Keys<EventDefinitions>>(
|
||||
eventType: K,
|
||||
listener: (...$ElementType<EventDefinitions, K>) => mixed,
|
||||
context: $FlowFixMe,
|
||||
): EmitterSubscription<EventDefinitions, K>;
|
||||
|
||||
removeAllListeners<K: $Keys<EventDefinitions>>(eventType: ?K): void;
|
||||
|
||||
emit<K: $Keys<EventDefinitions>>(
|
||||
eventType: K,
|
||||
...args: $ElementType<EventDefinitions, K>
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class EventEmitter
|
||||
* @description
|
||||
@@ -44,8 +30,7 @@ export interface IEventEmitter<EventDefinitions: {...}> {
|
||||
* mechanism on top of which extra functionality can be composed. For example, a
|
||||
* more advanced emitter may use an EventHolder and EventFactory.
|
||||
*/
|
||||
class EventEmitter<EventDefinitions: {...}>
|
||||
implements IEventEmitter<EventDefinitions> {
|
||||
class EventEmitter<EventDefinitions: {...}> {
|
||||
_subscriber: EventSubscriptionVendor<EventDefinitions> = new EventSubscriptionVendor<EventDefinitions>();
|
||||
|
||||
/**
|
||||
@@ -63,9 +48,6 @@ class EventEmitter<EventDefinitions: {...}>
|
||||
* emitted. An optional calling context may be provided. The data arguments
|
||||
* emitted will be passed to the listener function.
|
||||
*
|
||||
* TODO: Annotate the listener arg's type. This is tricky because listeners
|
||||
* can be invoked with varargs.
|
||||
*
|
||||
* @param {string} eventType - Name of the event to listen to
|
||||
* @param {function} listener - Function to invoke when the specified event is
|
||||
* emitted
|
||||
@@ -77,7 +59,7 @@ class EventEmitter<EventDefinitions: {...}>
|
||||
// FIXME: listeners should return void instead of mixed to prevent issues
|
||||
listener: (...$ElementType<EventDefinitions, K>) => mixed,
|
||||
context: $FlowFixMe,
|
||||
): EmitterSubscription<EventDefinitions, K> {
|
||||
): EventSubscription {
|
||||
return (this._subscriber.addSubscription(
|
||||
eventType,
|
||||
new EmitterSubscription(this, this._subscriber, listener, context),
|
||||
|
||||
Reference in New Issue
Block a user