Skip to content

Commit df092a5

Browse files
author
Patricio Vargas
committed
writting
1 parent a282a00 commit df092a5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/containers/Write.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
import React from 'react';
22

33
const Write = () => {
4+
5+
const onWrite = async() => {
6+
const abortController = new AbortController();
7+
abortController.signal.onabort = event => {
8+
alert('STOP');
9+
};
10+
try {
11+
const ndef = new window.NDEFReader();
12+
await ndef.write(
13+
{
14+
records: [{ recordType: "text", data: "17" }]
15+
},
16+
{signal: abortController.signal}
17+
);
18+
alert(`${16} saved!`);
19+
abortController.abort();
20+
} catch (error) {
21+
console.log(error);
22+
abortController.abort();
23+
}
24+
};
25+
26+
onWrite();
427
return (
528
"Write"
629
);

0 commit comments

Comments
 (0)