- From: François Beaufort via GitHub <sysbot+gh@w3.org>
- Date: Mon, 12 Aug 2019 11:15:16 +0000
- To: public-web-nfc@w3.org
beaufortfrancois has just created a new issue for https://github.com/w3c/web-nfc: == Expose WebNFC to workers == Moving Web APIs out of the main thread seems like [a good pattern](https://dassur.ma/things/when-workers/) for the Web and I'd argue WebNFC would be a great candidate. ```js // worker.js self.addEventListener("message", { action } => { const reader = new NFCReader({url: document.baseURI, recordType: "json"}); reader.addEventListener("reading", { message } => { for (const record of message.records) { const data = record.data(); self.postMessage({ data }); }); reader.start(); }); // main.js const worker = new Worker(); myWorker.addEventListener("message", { data } => { console.log('NFC message read from worker', data); }); worker.postMessage({ action: "read" }); ``` Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/293 using your GitHub account
Received on Monday, 12 August 2019 11:15:17 UTC