Skip to content

Commit

Permalink
oye
Browse files Browse the repository at this point in the history
  • Loading branch information
amark committed Feb 15, 2016
1 parent 3feb3f5 commit 7883bad
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gun.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ console.log("!!!!!!!!!!!!!!!! WARNING THIS IS GUN 0.4 !!!!!!!!!!!!!!!!!!!!!!");
Gun.on('put.ify').emit(gun, {lex: at.lex, node: node, err: err, opt: put.opt, data: data});
}, function(err, node, at){
if(err || node || opt.init || gun.__.opt.init){ return }
Gun.on('put.ify').emit(gun, {lex: at.lex, node: node, err: err, opt: at.opt, data: data});
at.lex.soul = at.lex.soul || gun.__.opt.uuid();
Gun.on('put.ify').emit(gun, {lex: at.lex, node: node, err: err, opt: at.opt, data: {}});
});
} else {
Gun.on('put.ify').emit(gun, {lex: {soul: gun.__.opt.uuid()}, opt: put.opt, data: data});
Expand Down
45 changes: 45 additions & 0 deletions lib/untitled
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
;(function(exports){ // On event emitter generic javascript utility.
function On(){ var on = this;
if(!On.is(on)){ return new On() }
return function(e, fn, i){ return on.e = e, fn? on.event(fn, i) : on };
};
On.is = function(on){ return (on instanceof On) }
On.chain = On.prototype;
On.chain.create = function(){ return On.call(null) }
var on = function(e){
on.event.e = e;
on.event.s[e] = on.event.s[e] || [];
return on;
};
On.chain.emit = function(a,b,c,d){
var on = this, e = on.e, s = on.s[e];
exports.list.map(s, function(at, i){ at.on(a,b,c,d) });
if(s && !s.length){ delete on.s[e] }
}
function At(fn, i){ var at = this;
if(!At.is(at)){ return new At() }
at.on = fn;
at.i = i; // TODO: MARK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! COME BACK HERE!
};
At.is = function(at){ return (at instanceof At) }
On.chain = On.prototype;
On.chain.event = function(fn, i){
//on.event = function(fn, i){
var on = this, e = on.e, s = on.s[e] = on.s[e] || [], at = At(fn, i);
var e = {fn: fn, i: i || 0, off: function(){ return !(e.fn = false) }}; // TODO: PERFORMANCE! Prototype-ify this and reduce any on complexity.
return s.push(e), i? s.sort(sort) : i, e;
}
//on.event.s = {};
//return on;

var sort = exports.list.sort('i');
exports.on = On; //On();
}(Gun || {}));


/*
on('foo', function(){

})

on('foo').emit('yay');*/

0 comments on commit 7883bad

Please sign in to comment.