include @d3x0r's update

This commit is contained in:
Mark Nadal 2017-02-09 12:28:06 -08:00
parent dbc398d6c4
commit d7062519a8
5 changed files with 17 additions and 10 deletions

4
gun.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -78,15 +78,12 @@ function output(at){
} else {
if(obj_has(cat, 'put')){
//if(u !== cat.put){
//cat.gun !== at.gun && console.log("Potential Bug? Is the map not getting called?");// TODO: BUG! If the map is uncached, so the `out` propagates up to the parent, which has a map on it, this will emit to the last subscriber (which may not be an `input`), which if it isn't... won't propagate back down!
cat.on('in', cat);
//cat.on('in').last.emit(cat);
} else// TODO: BUG! Handle plural chains by iterating over them.
if(cat.map){ // TODO: map will exist but different than if something in it.
if(cat.map){
obj_map(cat.map, function(proxy){
//console.log("CRASH3");
proxy.at.on('in', proxy.at);
//cat.on('in').last.emit(coat);
});
}
if(cat.ack){
@ -210,6 +207,9 @@ function map(data, key){ // Map over only the changes on every update.
return;
}
at = (gun._);
//if(data && data[_soul] && (tmp = Gun.val.rel.is(data)) && (tmp = (cat.root.get(tmp)._)) && obj_has(tmp, 'put')){
// data = tmp.put;
//}
if(at.field){
if(!(data && data[_soul] && Gun.val.rel.is(data) === Gun.node.soul(at.put))){
at.put = data;

View File

@ -24,7 +24,7 @@ Gun.chain.get = function(key, cb, as){
if(num_is(key)){
return this.get(''+key, cb, as);
} else {
(as = back.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
(as = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
if(cb){ cb.call(as, as._.err) }
return as;
}
@ -70,6 +70,7 @@ function use(at){
ev.to.next(at);
}
var obj = Gun.obj, obj_has = obj.has, obj_to = Gun.obj.to;
var num_is = Gun.num.is;
var rel = Gun.val.rel, node_ = Gun.node._;
var empty = {}, u;

View File

@ -12,6 +12,7 @@ Gun.chain.map = function(cb, opt, t){
return chain;
}
function map(at){
if(!at.put || Gun.val.is(at.put)){ return }
obj_map(at.put, each, {cat: this.as, gun: at.gun});
this.to.next(at);
}

View File

@ -59,18 +59,23 @@ Gun.chain.val = function(cb, opt){
}
function val(at, ev, to){
var opt = this.as, gun = at.gun, cat = gun._, data = cat.put || at.put;
var opt = this.as, cat = opt.cat, gun = at.gun, coat = gun._, data = coat.put || at.put;
if(u === data){
return;
}
if(ev.wait){ clearTimeout(ev.wait) }
if(!to && (!(0 < cat.ack) || ((true === opt.async) && 0 !== opt.wait))){
if(!to && (!(0 < coat.ack) || ((true === opt.async) && 0 !== opt.wait))){
ev.wait = setTimeout(function(){
val.call({as:opt}, at, ev, ev.wait || 1)
}, opt.wait || 99);
return;
}
if(ev.off()){ return } // if it is already off, don't call again!
if(cat.field || cat.soul){
if(ev.off()){ return } // if it is already off, don't call again!
} else {
if((opt.seen = opt.seen || {})[coat.id]){ return }
opt.seen[coat.id] = true;
}
opt.ok.call(at.gun || opt.gun, data, at.get);
}