mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
if chain cannot resolve, ack
This commit is contained in:
parent
e029dcd5ef
commit
e92aae7b55
13
gun.js
13
gun.js
@ -1079,7 +1079,7 @@
|
||||
if(!root.now || !root.now[at.id]){
|
||||
if((u === msg.put && !msg['@']) && null === tmp){ return }
|
||||
}
|
||||
if(u === tmp && at.put !== u){ return } // TODO: Bug? Threw second condition in for a particular test, not sure if a counter example is tested though.
|
||||
if(u === tmp && Gun.val.rel.is(at.put)){ return } // TODO: Bug? Threw second condition in for a particular test, not sure if a counter example is tested though.
|
||||
obj_map(tmp, function(proxy){
|
||||
if(!(proxy = proxy.at)){ return }
|
||||
obj_del(proxy.echo, at.id);
|
||||
@ -1147,16 +1147,15 @@
|
||||
}
|
||||
} else
|
||||
if(key instanceof Function){
|
||||
var gun = this, at = gun._, root = at.root._;
|
||||
var gun = this, at = gun._, root = at.root._, tmp = root.now, ev;
|
||||
as = cb || {};
|
||||
as.use = key;
|
||||
as.out = as.out || {};
|
||||
as.out.get = as.out.get || {};
|
||||
var tmp = at.on('in', use, as);
|
||||
if(root.now){ ++root.now.$ }
|
||||
(root.now || (root.now = {$:1}))[as.now = at.id] = tmp;
|
||||
ev = at.on('in', use, as);
|
||||
(root.now = {$:1})[as.now = at.id] = ev;
|
||||
at.on('out', as.out);
|
||||
if(!(--root.now.$)){ obj.del(root, 'now'); }
|
||||
root.now = tmp;
|
||||
return gun;
|
||||
} else
|
||||
if(num_is(key)){
|
||||
@ -1181,7 +1180,7 @@
|
||||
if(cat.root === back){
|
||||
at.soul = key;
|
||||
} else
|
||||
if(cat.soul || cat.field){ // TODO: Convert field to has!
|
||||
if(cat.soul || cat.field || cat.has){ // TODO: Convert field to has!
|
||||
at.field = at.has = key;
|
||||
if(obj_has(cat.put, key)){
|
||||
//at.put = cat.put[key];
|
||||
|
@ -3216,7 +3216,7 @@ describe('Gun', function(){
|
||||
});
|
||||
gun.get('parallel').get('bob').get('name').get(function(at, ev){
|
||||
var err = at.err, data = at.put, field = at.get;
|
||||
//console.log("*********** name", data, at.gun._.ack);return;
|
||||
//console.log("*********** name", data, at.gun._.ack);//return;
|
||||
expect(data).to.be('Bob!');
|
||||
expect(field).to.be('name');
|
||||
done.name = true;
|
||||
@ -3577,6 +3577,67 @@ describe('Gun', function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Nested listener should be called does it?', function(done){
|
||||
|
||||
var gun = Gun(), u;
|
||||
|
||||
gun.on('put', {gun: gun, put: Gun.graph.ify({
|
||||
wat: 1,
|
||||
a: true
|
||||
}, 'nl/app')});
|
||||
|
||||
var app = gun.get('nl/app');
|
||||
|
||||
app.get(function(d){
|
||||
expect(d.put.wat).to.be(1);
|
||||
expect(d.put.a).to.be(true);
|
||||
done.a = 1;
|
||||
});
|
||||
|
||||
//console.debug.i=1;console.log('-------------------');
|
||||
app.get('a').get('b').get(function(d){
|
||||
expect(d.put).to.be(u);
|
||||
expect(done.a).to.be.ok();
|
||||
if(done.c){ return }
|
||||
done(); done.c = 1;
|
||||
});
|
||||
window.app = app;
|
||||
return;
|
||||
});
|
||||
return;
|
||||
it('Nested listener should be called', function(done){
|
||||
|
||||
var gun = Gun();
|
||||
|
||||
var app = gun.get('nl/app').get('bar');
|
||||
|
||||
app.on(function(d){
|
||||
console.log("!!", d);
|
||||
})
|
||||
|
||||
app.put({wat: 1});
|
||||
|
||||
console.debug.i=1;console.log("------------");
|
||||
console.log(gun._.now);
|
||||
app.put({a: {b:2}});
|
||||
console.log('_______________________');
|
||||
return;
|
||||
|
||||
var app = gun.get('nl/app');
|
||||
var node = app.get('watcher/1').put({"stats":{"num":3},"name":"trex"});
|
||||
|
||||
app.get('watcher/1').get('stats').on(function (v, k) {
|
||||
console.log('v:', k, v);
|
||||
});
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
console.log("Huh?");
|
||||
app.get('watcher/1').put({"stats":{"num":4},"name":"trexxx"});
|
||||
|
||||
},100);
|
||||
});
|
||||
return;
|
||||
it.only('Memory management', function(done){
|
||||
this.timeout(9999999);
|
||||
|
Loading…
x
Reference in New Issue
Block a user