mirror of
https://github.com/amark/gun.git
synced 2025-07-05 04:12:32 +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
5
sea.js
5
sea.js
@ -710,9 +710,10 @@
|
|||||||
|
|
||||||
;USE(function(module){
|
;USE(function(module){
|
||||||
var Gun = USE('./sea').Gun;
|
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){
|
var gun = this, p = (new Promise(function(res, rej){
|
||||||
gun.once(res);
|
gun.once(res, opt);
|
||||||
}));
|
}));
|
||||||
return cb? p.then(cb) : p;
|
return cb? p.then(cb) : p;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
var Gun = require('./sea').Gun;
|
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){
|
var gun = this, p = (new Promise(function(res, rej){
|
||||||
gun.once(res);
|
gun.once(res, opt);
|
||||||
}));
|
}));
|
||||||
return cb? p.then(cb) : p;
|
return cb? p.then(cb) : p;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user