Re: [web-nfc] Consider using AbortController rather than a stop() method (#225)

I would strongly advocate for the use of the primitive `AbortController`. Reusing the same primitive everywhere we can has multiplicative beneficial effects throughout the web platform.
And I'd replace the start/stop pattern with a simple `read`(or `scan`) method.

```js
const reader = new NFCReader();
reader.onreading = e => { /* ... */ };
reader.onerror = e => { /* ... */ };

const controller = new AbortController();
controller.signal.onabort = e => {
  // We're done waiting for NFC tags.
});

reader.read({ signal: controller.signal });

// Stop reading NFC tags after 3s.
setTimeout(() => controller.abort(), 3000);
```

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

Received on Wednesday, 14 August 2019 10:29:38 UTC