Re: [presentation-api] Step 11 of getAvailability should not run "in parallel"

> If monitoring has not run before for the URLs in the request, we 
should wait until it completes to return a value.

"In parallel" gives the exact opposite result: it makes the monitoring
 run in the background and thus the promise gets resolved immediately 
(before monitoring is complete). Actually, we would not even need a 
Promise given that all other steps can run synchronously.

> If monitoring has run before then we can resolve immediately with a 
known value, and run it again to refresh the value.

A second call to `getAvailability` will always return the presentation
 availability promise set during the first call immediately (step 2). 
This aborts the rest of the algorithm. Which means step 11. will not 
run and the user agent is not required to run the monitoring algorithm
 again (it may still do so given that the spec says it may monitor on 
a continuous basis but that's not mandated in response to the second 
call to `getAvailability`).

> Practically speaking, I expect that developers will need to add an 
onchange handler to get correct availability information, so the page 
will always get the correct value eventually. I guess it's a question 
of whether they care that the initial value may be based on incomplete
 information.

I note that could affect tests as well, and @tomoyukilabs raised the 
question of the "initial value" in:
https://github.com/w3c/web-platform-tests/pull/4192#issuecomment-262725497

I would personally expect that initial value to convey "complete" 
information, meaning the "same" result as if I had called `start` 
instead of `getAvailability`. In other words, in simple scenarios, I 
would expect developers to be able to rely on the resolution of the 
Promise without having to listen to the `change` event. What would the
 Promise convey otherwise?

This is what the test on `PresentationAvailability` assumes for now.

-- 
GitHub Notification of comment by tidoust
Please view or discuss this issue at 
https://github.com/w3c/presentation-api/issues/381#issuecomment-264282425
 using your GitHub account

Received on Thursday, 1 December 2016 20:17:33 UTC