[web-nfc] Use addEventListener instead of watch

kenchris has just created a new issue for https://github.com/w3c/web-nfc:

== Use addEventListener instead of watch ==
I don't recall why we invented the watch, but it feels a bit like its own thing, instead of being aligned with the platform. We could go with a `startNotifications()` approach like WebBluetooth.

```js
navigator.nfc.addEventListener('exchange', message => {
  for (let record of message.records) {
    let article =/[aeio]/.test(record.data.title) ? "an" : "a";
    console.log(`${record.data.name} is ${article} ${record.data.title}`);
  }
},{
  url: document.baseURI,
  recordType: "json"
});

navigator.nfc.startNotifications();
```

Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/152 using your GitHub account

Received on Thursday, 27 September 2018 08:33:57 UTC