Skip to content

Commit

Permalink
Refactor PerformanceObserver public API
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

This is a follow-up to D40892974 (facebook@a671d61), addressing the post-land comments and discussions.

Reviewed By: rubennorte

Differential Revision: D40979654

fbshipit-source-id: 2e7e1d24be8211cc3363a07678745039e5606d8d
  • Loading branch information
rshest authored and facebook-github-bot committed Nov 3, 2022
1 parent bbd432e commit f32a3a5
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Libraries/WebPerformance/PerformanceObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@
* @flow strict
*/

'use strict';

export type Timestamp = number;
export type PerformanceEntryType = 'event';
export type HighResTimeStamp = number;
// TODO: Extend once new types (such as event) are supported
export type PerformanceEntryType = empty;

export class PerformanceEntry {
name: string;
entryType: PerformanceEntryType;
startTime: Timestamp;
startTime: HighResTimeStamp;
duration: number;

// For "event" entries only:
processingStart: ?Timestamp;
processingEnd: ?Timestamp;
interactionId: ?number;

// $FlowIgnore: Flow(unclear-type)
toJSON(): Object {
return {
Expand Down Expand Up @@ -73,12 +67,10 @@ export type PerformanceObserverCallback = (

export type PerformanceObserverInit =
| {
entryTypes: PerformanceEntryType[],
buffered?: boolean,
entryTypes: Array<PerformanceEntryType>,
}
| {
type: PerformanceEntryType,
buffered?: boolean,
};

/**
Expand Down Expand Up @@ -120,5 +112,7 @@ export default class PerformanceObserver {
return [];
}

static supportedEntryTypes: PerformanceEntryType[] = ['event'];
static supportedEntryTypes: $ReadOnlyArray<PerformanceEntryType> =
// TODO: add types once they are fully supported
Object.freeze([]);
}

0 comments on commit f32a3a5

Please sign in to comment.