Skip to content

Commit

Permalink
rm interface from RNPerfMetrics (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmondChuiHW authored Mar 22, 2024
1 parent a96803a commit 72fb914
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions front_end/core/host/RNPerfMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@

export type RNReliabilityEventListener = (event: ReactNativeChromeDevToolsEvent) => void;

type UnsunscribeFn = () => void;
export type RNPerfMetrics = {
addEventListener: (listener: RNReliabilityEventListener) => UnsunscribeFn,
removeAllEventListeners: () => void,
sendEvent: (event: ReactNativeChromeDevToolsEvent) => void,
};

let instance: RNPerfMetrics|null = null;

export function getInstance(): RNPerfMetrics {
if (instance === null) {
instance = new RNPerfMetricsImpl();
instance = new RNPerfMetrics();
}
return instance;
}

class RNPerfMetricsImpl implements RNPerfMetrics {
type UnsubscribeFn = () => void;
class RNPerfMetrics {
#listeners: Set<RNReliabilityEventListener> = new Set();

addEventListener(listener: RNReliabilityEventListener): () => void {
addEventListener(listener: RNReliabilityEventListener): UnsubscribeFn {
this.#listeners.add(listener);

const unsubscribe = (): void => {
Expand Down

0 comments on commit 72fb914

Please sign in to comment.