w3c / compute-pressure

A web API proposal that provides information about available compute capacity
https://www.w3.org/TR/compute-pressure/
Other
70 stars 10 forks source link

PressureRecord should be an interface, not a dictionary #136

Closed rakuco closed 2 years ago

rakuco commented 2 years ago

Apologies for filing this after #133, but I've only noticed this while reviewing #135 and checking other specs that use observers.

Calling a PressureUpdateCallback with a dictionary is semantically confusing, as:

MutationRecord, Report, IntersectionObserverEntry and PerformanceEntry are all IDL interfaces with read-only attributes, which better indicates how these data structures are supposed to be used.

Additionally, you could also use internal slots in PressureRecord if you make it an interface, which can also help with #132 if you e.g. use an internal slot with a set to represent factors.

(Note that if you do this factors needs to become a FrozenArray, as a sequence cannot be used as an attribute)