As easy as 1, 2, 3!
- Connect to a gun server.
- Save some data.
- Create a key to open it up later.
var gun = Gun('http://localhost:8888/gun');
gun.set({hello: 'world'}).key('my/first/data');
Disclaimer: This is a demo only! Data is deleted every 24 hours.
Let's test to see if the data got saved.
- Open this page in another browser tab.
- Now you'll see my/first/data load over there.
- Meanwhile, this textarea will wait for realtime updates from the other tab:
The next level will be unlocked when you complete the realtime sync between tabs.
var gun = Gun('http://localhost:8888/gun');
gun.load('my/first/data', function(err, data){
$('textarea').text(demo.print(data));
});
Does the key match from the previous tab?
Now let's listen to realtime updates, and change the value on the 'hello' field.
gun.load('my/first/data')
.on(function(updates){
$('textarea').text(demo.print(updates));
}).path('hello').set('You!');