Merge pull request #415 from amark/master

merge master INTO sea
This commit is contained in:
Mark Nadal 2017-09-10 13:51:07 -07:00 committed by GitHub
commit c9fa327836
3 changed files with 32 additions and 2 deletions

View File

@ -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
View 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
View 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);