Skip to content

Commit 12764f2

Browse files
committed
Update explainer because NDEFReader/NDEFWriter merge
Signed-off-by: Zoltan Kis <[email protected]>
1 parent 25bff7f commit 12764f2

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

EXPLAINER.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors:
66
- Francois Beaufort
77

88
Participate
9-
- https://github.com/w3c/web-nfc/issues/
9+
- https://github.com/w3c/web-nfc/issues/
1010
- https://lists.w3.org/Archives/Public/public-web-nfc/
1111

1212
## Introduction
@@ -93,14 +93,14 @@ info when users tap NFC devices can be done smoothly once permission is granted.
9393

9494
```js
9595
const reader = new NDEFReader();
96-
96+
9797
async function startScanning() {
9898
await reader.scan();
9999
reader.onreading = event => {
100100
/* handle NDEF messages */
101101
};
102102
}
103-
103+
104104
const nfcPermissionStatus = await navigator.permissions.query({ name: "nfc" });
105105
if (permissionStatus.state === "granted") {
106106
// NFC access was previously granted, so we can start NFC scanning now.
@@ -123,7 +123,7 @@ USB](https://wicg.github.io/webusb/) in that it offers secure low level access
123123
with no magic and instead exposes data as a DataView as well as requires text to
124124
be encoded and decoded using TextEncoder/TextDecoder, which allows handling
125125
cases where the text might even be in UTF-16 do to existing real life
126-
implementations.
126+
implementations.
127127

128128
```js
129129
const reader = new NDEFReader();
@@ -162,13 +162,12 @@ const abortController = new AbortController();
162162
abortController.signal.onabort = event => {
163163
// All NFC operations have been aborted.
164164
};
165-
166-
const reader = new NDEFReader();
167-
await reader.scan({ signal: abortController.signal });
168-
169-
const writer = new NDEFWriter();
170-
await writer.push("foo", { signal: abortController.signal });
171-
165+
166+
const ndef = new NDEFReader();
167+
await ndef.scan({ signal: abortController.signal });
168+
169+
await ndef.push("foo", { signal: abortController.signal });
170+
172171
document.querySelector("#abortButton").onclick = event => {
173172
abortController.abort();
174173
};
@@ -234,7 +233,7 @@ The reader and writer objects could have been merged into one single object, but
234233
as we allow multiple scans with filters to be active at the same time (maybe in
235234
multiple places/view of the app/site) then it makes more sense to be able to use
236235
separate objects.
237-
236+
238237
## Considered alternatives
239238

240239
### Restrict to NDEF and name accordingly

0 commit comments

Comments
 (0)