mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
commit
c9fa327836
@ -68,7 +68,7 @@
|
||||
<h3>Active</h3>
|
||||
|
||||
<div v-for="active in activeTodos">
|
||||
<label><input type="checkbox" @click="completeTodo(active.key)"> {{ active.todo.description }}</label>
|
||||
<label><input type="checkbox" @click.prevent="completeTodo(active.key)"> {{ active.todo.description }}</label>
|
||||
</div>
|
||||
|
||||
<h5 v-show="completedTodos.length > 0" class="completed-header">Completed</h5>
|
||||
@ -160,4 +160,4 @@ new Vue({
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
10
lib/promise.js
Normal file
10
lib/promise.js
Normal file
@ -0,0 +1,10 @@
|
||||
var Gun = Gun || require('../gun');
|
||||
|
||||
Gun.chain.promise = function(field) {
|
||||
var gun = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
gun.get(field).val(function(node, key) {
|
||||
resolve(node, key);
|
||||
});
|
||||
});
|
||||
};
|
20
promise-test.js
Normal file
20
promise-test.js
Normal file
@ -0,0 +1,20 @@
|
||||
var Gun = require('./gun');
|
||||
require('./lib/promise');
|
||||
|
||||
var gun = new Gun();
|
||||
|
||||
gun.get('mark').put({
|
||||
name: 'mark'
|
||||
})
|
||||
|
||||
async function getField(field) {
|
||||
var node = await gun.promise(field);
|
||||
console.log(node);
|
||||
return node;
|
||||
};
|
||||
|
||||
setTimeout(async () => {
|
||||
var mark = await getField('mark');
|
||||
console.log(mark);
|
||||
process.exit();
|
||||
}, 100);
|
Loading…
x
Reference in New Issue
Block a user