mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
add: wait for once, so data is returned on first get (#6)
* add: wait for once, so data is returned on first get * Update then.js
This commit is contained in:
parent
29ed57e955
commit
512d2c8c32
7
sea.js
7
sea.js
@ -710,9 +710,10 @@
|
||||
|
||||
;USE(function(module){
|
||||
var Gun = USE('./sea').Gun;
|
||||
Gun.chain.then = function(cb){
|
||||
Gun.chain.then = function(cb, opt = {}){
|
||||
opt = {wait: 200, ...opt}
|
||||
var gun = this, p = (new Promise(function(res, rej){
|
||||
gun.once(res);
|
||||
gun.once(res, opt);
|
||||
}));
|
||||
return cb? p.then(cb) : p;
|
||||
}
|
||||
@ -1336,4 +1337,4 @@
|
||||
// TODO: Potential bug? If pub/priv key starts with `-`? IDK how possible.
|
||||
|
||||
})(USE, './index');
|
||||
}());
|
||||
}());
|
||||
|
@ -1,9 +1,10 @@
|
||||
|
||||
var Gun = require('./sea').Gun;
|
||||
Gun.chain.then = function(cb){
|
||||
Gun.chain.then = function(cb, opt = {}){
|
||||
opt = {wait: 200, ...opt}
|
||||
var gun = this, p = (new Promise(function(res, rej){
|
||||
gun.once(res);
|
||||
gun.once(res, opt);
|
||||
}));
|
||||
return cb? p.then(cb) : p;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user