Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export default class EventEmitter<
// Copy `registrations` to take a snapshot when we invoke `emit`, in case
// registrations are added or removed when listeners are invoked.
for (const registration of Array.from(registrations)) {
// $FlowFixMe[incompatible-type]
registration.listener.apply(registration.context, args);
}
}
Expand Down Expand Up @@ -159,7 +158,6 @@ export default class EventEmitter<
function allocate<
TEventToArgsMap: Readonly<Record<string, ReadonlyArray<UnsafeEventObject>>>,
TEvent: $Keys<TEventToArgsMap>,
TEventArgs: TEventToArgsMap[TEvent],
>(
registry: Registry<TEventToArgsMap>,
eventType: TEvent,
Expand Down
39 changes: 31 additions & 8 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9504863966549f8efbbe4e13d7f74eaf>>
* @generated SignedSource<<532b4c9c3a1d7ea9cbfce8c8e8ff3d87>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
Expand Down Expand Up @@ -1865,7 +1865,7 @@ declare namespace CodegenTypes {
UnsafeMixed,
DefaultTypes,
WithDefault,
EventEmitter,
EventEmitter_2 as EventEmitter,
}
}
declare type ColorListenerCallback = (value: ColorValue) => unknown
Expand Down Expand Up @@ -2229,7 +2229,28 @@ declare type EventConfig<T> = {
platformConfig?: PlatformConfig
useNativeDriver: boolean
}
declare type EventEmitter<T> = (
declare class EventEmitter<
TEventToArgsMap extends Readonly<
Record<string, ReadonlyArray<UnsafeEventObject>>
> = Readonly<Record<string, ReadonlyArray<UnsafeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
addListener<TEvent extends keyof TEventToArgsMap>(
eventType: TEvent,
listener: (...args: TEventToArgsMap[TEvent]) => unknown,
context: unknown,
): EventSubscription
constructor()
emit<TEvent extends keyof TEventToArgsMap>(
eventType: TEvent,
...args: TEventToArgsMap[TEvent]
): void
listenerCount<TEvent extends keyof TEventToArgsMap>(eventType: TEvent): number
removeAllListeners<TEvent extends keyof TEventToArgsMap>(
eventType?: null | TEvent | undefined,
): void
}
declare type EventEmitter_2<T> = (
handler: ($$PARAM_0$$: T) => Promise<void> | void,
) => EventSubscription
declare type EventName = (() => string) | string
Expand Down Expand Up @@ -5988,15 +6009,15 @@ export {
Button, // ef82aed4
ButtonProps, // 3c081e75
Clipboard, // 41addb89
CodegenTypes, // 030a94b8
CodegenTypes, // adbc477c
ColorSchemeName, // 31a4350e
ColorValue, // 98989a8f
ComponentProvider, // b5c60ddd
ComponentProviderInstrumentationHook, // 9f640048
CursorValue, // 26522595
DevMenu, // 21b8b7a9
DevSettings, // e55b91dc
DeviceEventEmitter, // 650e6394
DeviceEventEmitter, // bdbdd014
DeviceInfo, // 521bfb71
DeviceInfoConstants, // 279e7858
DimensionValue, // b163a381
Expand All @@ -6016,6 +6037,7 @@ export {
EmitterSubscription, // de50c359
EnterKeyHintTypeOptions, // 8314de78
ErrorUtils, // 38fb909e
EventEmitter, // 2a2ea995
EventSubscription, // b8d084aa
ExtendedExceptionData, // 5a6ccf5a
FilterFunction, // bf24c0e3
Expand All @@ -6029,6 +6051,7 @@ export {
HostComponent, // 5e13ff5a
HostInstance, // 489cbe7f
I18nManager, // f9870e00
IEventEmitter, // fbef6131
IOSKeyboardEvent, // e67bfe3a
IgnorePattern, // ec6f6ece
Image, // 957b3726
Expand Down Expand Up @@ -6074,7 +6097,7 @@ export {
LayoutChangeEvent, // c674f902
LayoutConformanceProps, // 055f03b8
LayoutRectangle, // 6601b294
Linking, // b5645d2b
Linking, // 9a6a174d
ListRenderItem, // b5353fd8
ListRenderItemInfo, // e8595b03
ListViewToken, // 833d3481
Expand All @@ -6090,11 +6113,11 @@ export {
ModalPropsIOS, // 4fbcedf6
ModeChangeEvent, // 16790307
MouseEvent, // 53ede3db
NativeAppEventEmitter, // e1340a0a
NativeAppEventEmitter, // 08d4c47d
NativeColorValue, // d2094c29
NativeComponentRegistry, // 7fd99ba6
NativeDialogManagerAndroid, // 5be8497e
NativeEventEmitter, // d72906cc
NativeEventEmitter, // 27f97c1a
NativeEventSubscription, // de3942e7
NativeMethods, // 03dc51c5
NativeMethodsMixin, // 4b061b7e
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ module.exports = {
return require('./Libraries/Components/DrawerAndroid/DrawerLayoutAndroid')
.default;
},
get EventEmitter() {
return require('./Libraries/vendor/emitter/EventEmitter').default;
},
get FlatList() {
return require('./Libraries/Lists/FlatList').default;
},
Expand Down
7 changes: 6 additions & 1 deletion packages/react-native/index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ export * as NativeComponentRegistry from './Libraries/NativeComponent/NativeComp
export {default as NativeDialogManagerAndroid} from './Libraries/NativeModules/specs/NativeDialogManagerAndroid';

export type {
EventSubscription,
EmitterSubscription,
NativeEventSubscription,
} from './Libraries/EventEmitter/NativeEventEmitter';
Expand Down Expand Up @@ -463,6 +462,12 @@ export type {
PublicTextInstance,
} from './Libraries/ReactPrivate/ReactNativePrivateInterface';

export type {
EventSubscription,
IEventEmitter,
} from './Libraries/vendor/emitter/EventEmitter';
export {default as EventEmitter} from './Libraries/vendor/emitter/EventEmitter';

export {
default as unstable_VirtualView,
VirtualViewMode,
Expand Down
Loading