Re: [web-nfc] Allow nfc.push to accept a dictionary

Another way would be to separate the URL path from the records, in 
fact the path goes to the separate Web NFC record. IMHO the path could
 be included into the PushOptions or as a separate parameter.
The first parameter to ```push()``` would be the data in payload: 
- either a ```DOMString``` (text tag), or ```ArrayBuffer``` (media tag
 with ```application/octet-stream```,  or a dictionary (single 
object), as media tag with ```application/json```; in all these cases 
we push one record
- or, if it is instanceof ```Array```, then the elements should be 
```NFCRecord```s.

Then, pushing JSON would be simple:
``` await nfc.push({ name: "ping", value: "pong" }, 
"/tabletennis/run");  // default push options```

Simplifying the single record use cases would be indeed important, 
since IMHO these would make up the majority of the API usages. 
Therefore I'd prefer this way to making NFCMessage constructible, 
although that's a valid option too.



-- 
GitHub Notification of comment by zolkis
Please view or discuss this issue at 
https://github.com/w3c/web-nfc/issues/104#issuecomment-219160506 using
 your GitHub account

Received on Friday, 13 May 2016 21:12:38 UTC