amark on master
ok ack + webrtc Merge branch 'master' of http:/… bump (ok ack + webrtc) @Draeder… (compare)
amark on master
websocket ../index to ./index (… (compare)
amark on master
PANIC tests + AXE get dedup + f… Merge branch 'master' of http:/… (compare)
amark on master
lib/ison: Use setTimeout instea… (compare)
[D]anoxy: @pszabop in fact it is possible to have aliases exactly as it works in Discord like anoxy#4831
. <@280426612900757504> have implemented it in his platform https://www.peersocial.io/
So by doing it that way there won't be any name collisions
—
Anyone else - is there a way to mutate a value without referencing it (e.g. gun.get(‘someitem’).get(‘views’).inc()
to increment? Maybe a custom chain method that will call a method on a node with itself as a parameter? That possibly is already written, I’m just thinking out loud here:
Gun.prototype.call( function( Function cb ) {
this.put(cb(this))
})
And then we could do:
Gun.prototype.inc( function() {
this.call( function(x) { return x++ } )
})
Gun.chain.inc = function () {
let self = this;
this.get('.').once(function(data,key){
console.log("data",data,"key",key);
if(!data) data = 0;
data = data+1;
console.log("data",data,"key",key);
return self.put({[key]:data});
});
}
// usage:
gun.get('something').get('views').inc();
// read count
gun.get('something').get('views').get('.').once(function(count){ // count should be now 1 });
Gun.chain.curval = async function(){
return await this.get('.').then();
}
//usage:
let views= await gun.get("whatever").get("inc2").curval();
// should return whatever was incremented
@KINKCreative ah, i see... you want the tags per node. While the purpose of gun-tag is to get all nodes tagged to something, you want it the other way around ;)
Well , whenever a node is tagged, the tag is added to the property 'tags' ( as you noticed ) the difference between tag and untag is 1 (tagged) or 0 (untagged).
So (using my example provided in my github comment )
gun.get('alex').get('tags').once(tags=>{
var t = Gun.obj.copy(tags)
delete t._
console.log(t) // {member:0,paid:1}
})
So alex is untagged from 'member' but tagged to 'paid'
Does this answer your question ?
@Stefdv Yes that much I figured, thanks!
I was wondering if it would be a huge workaround the difference between tag and untag is not 1 & 0 but instead an int number of total numbers of such tag? (say, I have 10 people tagging an item with ‘like’, wouldn’t it be cool if the response would say { like: 10 }
.obj.copy(…)
- is that different from open()
or load()
?
Gun('peer'
Gun(['peer', 'peer
Gun({peers: [
Gun({peers: {
etc. guessing somebody else already helped.await SEA.pair()
gun.on('auth
versus Gun.on('auth
I think it is just that your phone auto capitalizes stuff 😛 but important subtle difference. I want to make user.on('auth'
work but lol it is buggy.user.leave()
is synchronous, no event for it currently.to.next(e
in auth
when I need to, it should support multiple, if not, that is a bug. Should be easy fix, wanna try?SEA.opt.pub('asdf~lol.yay.what')
which returns the PubKey portion of that "soul" or undefined. Does that help?
Gun.chain.myExtension = function(){ var gun = this; return gun }
super easy to make custom extensions 😄 goal is to wrap even app-specific logic into little "macros" you reuse in your app instead of GUN's core API. Things like increment/decrement require a special CRDT, can be done in like 12 LOC, see this page: https://gun.eco/docs/Counter + <@!648558515463651338> if you're curious too (what is curval
?).Gun.chain.incrval = function () {
let self = this;
this.get('.').once(function(data,key){
if(typeof data === "undefined") data = 0;
data = data+1;
return self.put({[key]:data});
});
}
Gun.chain.decrval = function(){
let self = this;
this.get('.').once(function(data,key){
if(typeof data === "undefined") data = 0;
data = data-1;
return self.put({[key]:data});
});
}
Gun.chain.currval = async function(){
let curr = await this.get('.').then();
if(!curr) curr = 0;
return curr;
}
//usage:
gun.get("stuff").get("views").incrval() // data is 0+1
gun.get("stuff").get("views").currval() // 1
gun.get("stuff").get("views").incrval() // data is 1+1
gun.get("stuff").get("views").currval() // 2
gun.get("stuff").get("views").decrval() // data is 2-1
//etc
Gun({peers:{"url-address/gun":{}})
to the constructor, it doesn't work
if(gun && !Nug) Nug = new Gun({peers:Object.keys(gun._.opt.peers)});
to get it working, so there should be checking whether it's an array or an object, as the obj_map(tmp...
fails miserably with object constructor on opts.peers 🙂