Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace $ObjMap in EventEmitter with mapped type #46332

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions packages/react-native/Libraries/vendor/emitter/EventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ interface Registration<TArgs> {
+remove: () => void;
}

// $FlowFixMe[deprecated-type]
type Registry<TEventToArgsMap: {...}> = $ObjMap<
TEventToArgsMap,
<TArgs>(TArgs) => Set<Registration<TArgs>>,
>;
type Registry<TEventToArgsMap: {...}> = {
[K in keyof TEventToArgsMap]: Set<Registration<TEventToArgsMap[K]>>,
};

/**
* EventEmitter manages listeners and publishes events to them.
Expand All @@ -64,6 +62,7 @@ type Registry<TEventToArgsMap: {...}> = $ObjMap<
export default class EventEmitter<TEventToArgsMap: {...}>
implements IEventEmitter<TEventToArgsMap>
{
// $FlowFixMe[incompatible-type]
#registry: Registry<TEventToArgsMap> = {};

/**
Expand Down Expand Up @@ -126,6 +125,7 @@ export default class EventEmitter<TEventToArgsMap: {...}>
eventType?: ?TEvent,
): void {
if (eventType == null) {
// $FlowFixMe[incompatible-type]
this.#registry = {};
} else {
delete this.#registry[eventType];
Expand Down
Loading