diff --git a/Libraries/vendor/emitter/_EventEmitter.js b/Libraries/vendor/emitter/_EventEmitter.js index 4cf99a6971b..998f5cec747 100644 --- a/Libraries/vendor/emitter/_EventEmitter.js +++ b/Libraries/vendor/emitter/_EventEmitter.js @@ -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 { - addListener>( - eventType: K, - listener: (...$ElementType) => mixed, - context: $FlowFixMe, - ): EmitterSubscription; - - removeAllListeners>(eventType: ?K): void; - - emit>( - eventType: K, - ...args: $ElementType - ): void; -} - /** * @class EventEmitter * @description @@ -44,8 +30,7 @@ export interface IEventEmitter { * mechanism on top of which extra functionality can be composed. For example, a * more advanced emitter may use an EventHolder and EventFactory. */ -class EventEmitter - implements IEventEmitter { +class EventEmitter { _subscriber: EventSubscriptionVendor = new EventSubscriptionVendor(); /** @@ -63,9 +48,6 @@ class EventEmitter * 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 // FIXME: listeners should return void instead of mixed to prevent issues listener: (...$ElementType) => mixed, context: $FlowFixMe, - ): EmitterSubscription { + ): EventSubscription { return (this._subscriber.addSubscription( eventType, new EmitterSubscription(this, this._subscriber, listener, context),