-
-
Save hillct/d385f747715194fb69736c4e1ad0b719 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/metabadano
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://rawgit.com/amark/gun/0.5/gun.js"></script> | |
<script id="jsbin-javascript"> | |
localStorage.clear(); | |
var gun = Gun(); | |
var list = gun.get('list'); | |
var item1 = gun.get('alice').put({name: "alice"}); | |
list.set(item1); | |
var item2 = gun.get('bob').put({name: "bob"}); | |
list.set(item2); | |
// because `set` uses the key as the index in the list... | |
// I can use that key to find the item in the list and null it. | |
// Of course, if you have dynamic IDs of items in the set, | |
// you would somehow have to figure the ID out first, and then do this. | |
list.path('bob').put(null); // de-reference | |
// now let's look at what the list, as a whole, looks like now... | |
list.val(function(data){ | |
console.log(data); // notice alice retains her pointer, while bob does not. | |
}) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">localStorage.clear(); | |
var gun = Gun(); | |
var list = gun.get('list'); | |
var item1 = gun.get('alice').put({name: "alice"}); | |
list.set(item1); | |
var item2 = gun.get('bob').put({name: "bob"}); | |
list.set(item2); | |
// because `set` uses the key as the index in the list... | |
// I can use that key to find the item in the list and null it. | |
// Of course, if you have dynamic IDs of items in the set, | |
// you would somehow have to figure the ID out first, and then do this. | |
list.path('bob').put(null); // de-reference | |
// now let's look at what the list, as a whole, looks like now... | |
list.val(function(data){ | |
console.log(data); // notice alice retains her pointer, while bob does not. | |
})</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localStorage.clear(); | |
var gun = Gun(); | |
var list = gun.get('list'); | |
var item1 = gun.get('alice').put({name: "alice"}); | |
list.set(item1); | |
var item2 = gun.get('bob').put({name: "bob"}); | |
list.set(item2); | |
// because `set` uses the key as the index in the list... | |
// I can use that key to find the item in the list and null it. | |
// Of course, if you have dynamic IDs of items in the set, | |
// you would somehow have to figure the ID out first, and then do this. | |
list.path('bob').put(null); // de-reference | |
// now let's look at what the list, as a whole, looks like now... | |
list.val(function(data){ | |
console.log(data); // notice alice retains her pointer, while bob does not. | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment