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
Move watch options to NFCReader ctor #180
Conversation
index.html
Outdated
<a>For each</a> <var>key</var> → <var>value</var> of <var>options</var>: | ||
<ul> | ||
<li> | ||
If the <a>NFCReaderOptions</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be NFCReader, because otherwise I will copy signal
as well. Maybe I should just list our the attributes? @anssiko
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: If you have a normative definition here, then lines 1478-1482 should be a note. But, in WebIDL, attributes are getter/setters, not own properties, so their definition isn't determined by setting the attribute to a value, but saying that, when you read the attribute, you get that value.
attribute EventHandler onreading; | ||
|
||
Promise<void> watch(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO removing the argument of watch()
and passing it to the constructor is half-breed solution.
I would use either watch()
with the options, or constructor with the function passed together with options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an incremental change to make sure it all works, watch()
will be removed soon enough and it will be activated when event listener is attached
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incremental changes SGTM. I like the plan of activating when the event listener is attached.
@zolkis You might want to avoid using analogies like "half-breed", which could be considered demeaning.
USVString url = ""; | ||
NFCRecordType recordType; | ||
USVString mediaType = ""; | ||
NFCWatchMode mode = "web-nfc-only"; | ||
NFCAccept accept = "web-nfc-only"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't accept
a bit overloaded? I feel that mode
was better compromise for capturing what it is an accept-policy then just accept
. Unless accept
has one well defined meaning and usage in other specs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used by http at least. Maybe we can find a better name, but for now, WatchMode doesn't make so much sense as I am removing watch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accept
SGTM; the analogy makes sense
<p> | ||
This enum defines the set of known values denoting whether | ||
<code><a href="#dom-nfcreader-watch">watch()</a></code> operation should | ||
<a>dispatch NFC content</a> for <a>Web NFC content</a> or any | ||
<a>NFC content</a> | ||
</p> | ||
<pre class="idl"> | ||
enum NFCWatchMode { | ||
enum NFCAccept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above with accept
being overloaded term in comms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name isn't web-exposed, so I don't think it matters so much to decide the perfect one right now.
index.html
Outdated
<p> | ||
The <dfn>NFCReader.url</dfn>, <dfn>NFCReader.recordType</dfn>, | ||
<dfn>NFCReader.mediaType</dfn> and <dfn>NFCReader.accept</dfn> correlates to | ||
the members of <a>NFCReaderOptions</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/correlates the/have the values of the corresponding/ (when correlates is used as a transitive verb, the subject is the person doing the analysis)
index.html
Outdated
<ul> | ||
<li> | ||
If the <a>NFCReaderOptions</a> | ||
<a data-lt="list-contain">contains</a> <var>key</var>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WebIDL will already filter out the irrelevant keys, so I don't think this conditional is necessary. Or did you mean to check whether NFCReader contains the key, to filter out signal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was based of generic sensor spec (geolocation sensor)
index.html
Outdated
@@ -2633,7 +2674,7 @@ <h2>The <dfn>NFCWatchMode</dfn> enum</h2> | |||
</p> | |||
<p> | |||
An <dfn>NFC watch</dfn> is referring to a tuple of a <code><a>Promise</a></code>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English nit: s/is referring to/refers to/
index.html
Outdated
@@ -2710,7 +2748,7 @@ <h2>The <dfn>NFCWatchMode</dfn> enum</h2> | |||
<code>"NotSupportedError"</code> and return <var>p</var>. | |||
</li> | |||
<li> | |||
If the <var>options</var>.url is not an empty <code>String</code> | |||
If the <var>reader_instance</var>.url is not an empty <code>String</code> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, somehow this text should clarify, you don't mean Get(reader_instance, "url")
(since that could be modified using Object.defineProperty), but you mean the original value. You could specify this using internal slots, or a single big internal slot for the options dictionary.
index.html
Outdated
readonly attribute USVString url; | ||
readonly attribute NFCRecordType recordType; | ||
readonly attribute USVString mediaType; | ||
readonly attribute NFCAccept accept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, what is the motivation for exposing these to read out? It seems like this will just be the options that were passed in, so I don't really see the use case. Did you just add these attributes so that they were stored internally in the NFCReader? You might want to use internal slots for that purpose, if so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you are right... I was thinking about it being nice to store if you had multiple readers but I guess we can just drop that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest thing I'd want clarified before approving is whether you intended to expose the options as attributes; besides that, all comments are editorial and would be fine to clean up later.
index.html
Outdated
<var>message</var>.url as a <code><a>Web NFC Id</a></code>. If | ||
<a href="#dfn-match-web-nfc-id-with-url-pattern">URL pattern match</a> | ||
algorithm returns <code>false</code>, skip to the next <a>NFC watch</a>. | ||
</li> | ||
<li> | ||
If <var>options</var>.recordType is <a href=#dfn-not-present>present</a> and | ||
it is not equal to any <var>record</var>.recordType where <var>record</var> | ||
If <var>reader_instance</var>.[[\RecordType] is <a href=#dfn-not-present>present</a> and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: missing ]
index.html
Outdated
If <var>options</var>.recordType is <a href=#dfn-not-present>present</a> and | ||
it is not equal to any <var>record</var>.recordType where <var>record</var> | ||
If <var>reader_instance</var>.[[\RecordType] is <a href=#dfn-not-present>present</a> and | ||
it is not equal to any <var>record</var>.[[\recordType]] where <var>record</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the type of these records defined?
Probably either both this line and line 3041 should use internal slot notation or property notation, but not one of each.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are internal slots on the NFCReader. But the NFCRecord (the data we read) has these as properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to define the internal slots for the NFCReader somewhere. Can be a follow-up
This is an incremental change, as
watch
will be removed in future PR