Skip to content

Commit

Permalink
Replace $ObjMap in EventEmitter with mapped type (#46332)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46332

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D62199703

fbshipit-source-id: 24abf39b01d5ba8a90e03ce837a887d4b4f4ade8
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Sep 4, 2024
1 parent e864663 commit 464a202
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 464a202

Please sign in to comment.