Re: [compute-pressure] Get rid of the promise returned by observe (#258)

Not sure I can contribute much other than making comparisons to the Performance API :)

> Also users just observe and get events as soon as the system can deliver them. 

So, I guess to me this is a limitation in `PressureObserver`. In `PerformanceObserver` you have the option to retrieve data from a buffer using the `buffered` option in `observe()`. This allows you to look at data occurred before observation basically and not only just-in-time. So, if the buffer is empty, nothing happened before... Is that what you want to check for in tests?

> or it could fire an "error" event if something in observe() goes wrong

Again, drawing the comparison to the `PerformanceObserver`, it seems that [nothing happens](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe). "Unrecognized types are ignored, though the browser may output a warning message to the console to help developers debug their code. If no valid types are found, observe() has no effect."

> Would it be _that_ important to support multiple sources in one call instead of having developers do something like `Promise.all([observer.observe('gpu'), observer.observe('thermal', options), observer.observe('gpu', options)])`?

I think that might work? I guess the multiple sources use case is basically: "I want to check all available sources and if I see pressure anywhere, I want to do something about it or log it for analytics". And because `PressureRecord.source` is available I can filter the data as needed later on, so I might as well ask the system for everything it can possibly have for me.

-- 
GitHub Notification of comment by Elchi3
Please view or discuss this issue at https://github.com/w3c/compute-pressure/issues/258#issuecomment-2049493202 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 11 April 2024 11:33:49 UTC