New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NDEFReader.scan should say when it resolves and returns the promise p #478
Comments
This still doesn't seem right, at least based on something that would make the examples work. Having "resolve p" as step 7 makes it sound like the promise doesn't get resolved until after the browser stops trying to detect NFC technology. I suspect the intent is to resolve the promise after "4. Add reader to the activated reader objects.", although it's possible that it could be right before (4) as well (which would be detectably different). |
(I'd also note that (2) and (3) don't really seem like separate steps. But it also seems like, implicitly, between them, there's something like "wait for this request to ???", so that they could be combined as something like: " If this is the first listener being set up, then make a request to all NFC adapters to listen to NDEF messages. Wait for this request to ???. If the request fails, then the UA MAY reject p with a "NotSupportedError" DOMException and abort these steps." (Though this also seems to forbid a UA from trying again if it fails once, which might be undesirable.) Likewise, it's not clear to me that step 5, currently:
is really a step that happens chronologically. |
I should have resolved |p| earlier to make it clear indeed. I've opened #483 to fix it.
@zolkis @kenchris I'm not sure what "make a request to all NFC adapters to listen to NDEF messages." means? Is this a concept from the previous spec version? We're already checking if no underlying NFC Adapter, if a connection cannot be established, and if the UA is not allowed to access the underlying NFC Adapter (e.g. a user preference) earlier, so I'm not sure what this refers to?
As we already have https://w3c.github.io/web-nfc/#handling-visibility-change, we may want to remove step 5 here. What do you think @kenchris @zolkis? |
If there are multiple NFC adapters (e.g. a built-in and a USB adapter), they are all used in parallel. There is no API needed to list them or select one. It does not matter which one makes the reading (the closest). |
I agree. |
@dbaron I believe all your feedback has been addressed. See https://w3c.github.io/web-nfc/#the-scan-method
|
So currently the text of step 7 says:
This now seems pretty close, except that items (2) and (3) above should say "and abort these steps" instead of "and return p". |
@dbaron Thanks for raising the issue. I've fixed text. |
So reading through the examples in the explainer, one thing I wondered was that it seems a little odd to do the asynchronous
await reader.scan()
and then set thereader.onreading
property to an event handler. It made me wonder whether thereading
events could happen during thereader.scan()
call. So I decided to look at the spec text forreader.scan()
to understand whether this is the case -- and I ran into a problem. As far as I can tell, nothing in that algorithm ever resolves and returnsp
in the success case -- which seems to imply that the function never returns at all!I think there should be something in that spec text that says to resolve
p
and return it in the success case. (At least I think that's how promise-using specifications are supposed to be written, although I suppose there actually isn't anything in the promises guide saying so.)(I got here from w3ctag/design-reviews#461.)
The text was updated successfully, but these errors were encountered: