39 lines
835 B
HTML
39 lines
835 B
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<title>demo</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<script type="module">
|
||
|
import GUN from 'gun'
|
||
|
import SEA from 'gun/sea'
|
||
|
|
||
|
const gun = GUN({
|
||
|
peers: ['http://localhost:8000/gun'],
|
||
|
localStorage: false
|
||
|
})
|
||
|
|
||
|
gun.get('text').once((node) => {
|
||
|
console.log("Receiving Initial Data")
|
||
|
console.log(node)
|
||
|
})
|
||
|
|
||
|
gun.get('text').put({
|
||
|
text: 'Hello World'
|
||
|
})
|
||
|
|
||
|
gun.get('text').on((node) => {
|
||
|
console.log("Receiving Update")
|
||
|
console.log(node)
|
||
|
})
|
||
|
|
||
|
document.addEventListener('click', () => {
|
||
|
gun.get('text').put({
|
||
|
text: 'Hello World'
|
||
|
})
|
||
|
})
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|