Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
haveanicedavid
@haveanicedavid:matrix.org
[m]
@amark: are you open to the idea of something like a linter / formatter in the gun codebase? Or a PR that just focused on organizing the code stylistically without touching logic? I imagine you might get more contributions if things were a bit easier to follow - I'm trying to learn some of the internal snow to understand what's gong on with a LEX query that's blowing up for me, and it's really hard to track what's going on
rococtz
@rococtz:matrix.org
[m]
@SuleimanZhukov: You ensure the data is correct by using SEA.sign and SEA.verify.
You have to create your own relay. Where would you run it otherwise? Who is willing to spend time and money only to deploy an app on a community relay? Are you willing to to store all your app data on some community relay that might disappear tomorrow?
@AlexZan: There is a whole directory for the tests in here https://github.com/amark/gun/tree/master/test
Also, under tests, there is a directory called panic which looks more like integration tests
Ilham Gumilang
@ilhamgum
@draeder so checking through user.is() is not enough right? i'll keep that in mind, thx a lot Daniel:D
Nick Baroni
@rhythnic

Hello! I'm having an issue with the on callback not firing after calling set(gun.put(data)). set(data) does cause the on callback to fire.

gun.get('list').map().on((data, id) => {
  // fires when data added directly to set()
  // doesn't fire when the put() result is added to set()
})

const save = data => {
    if(data.id) {
      gun.get(data.id).put(data);  
    } else {
      const node = gun.put(data);
      gun.get('list').set(node);
   }
}

GunDB newbie here so I'm probably overlooking something. Also, is this the best practice approach for maintaining sets of data? Do most people using Gun use a uuid library or let Gun create the key?

Nick Baroni
@rhythnic
The callback fires if the ID is not at the root level.
gun.get('list').map().on((data, key) => {
  const [_, id] = key.split('/');
  // ...
})

const save = data => {
    if(data.id) {
      gun.get('collection').get(data.id).put(data);  
    } else {
      const node = gun.get('collection').put(data);
      gun.get('list').set(node);
   }
}
haveanicedavid
@haveanicedavid:matrix.org
[m]
will there always be an ack.ok on successful writes?
docs are a little unclear to me. Also apparently can't copy + paste text from docs :D
if there was a success message (none is required though)
Suleiman Zhukov
@SuleimanZhukov

@rococtz:matrix.org Thank you for the answer.
And how many relay servers should I create?

Sorry for these dumb questions, but I am really really confused here a little.

Suleiman Zhukov
@SuleimanZhukov
And what does this code mean?
var chat = gun.get("converse/" + location.hash.slice(1))
Suleiman Zhukov
@SuleimanZhukov
And what is Gun.state()?
rococtz
@rococtz:matrix.org
[m]
@SuleimanZhukov: One server is enough (assuming you use it with S3 backup), but of course, the more the better. The problem is that there are some performance bugs happening and you can get memory issues when you use more than one. I don't think that problem was solved.
I don't know what that code means. Probably someone put items in gun.get('converse').get('id').put(chatData) and now they are trying to retrieve them
also, I have no idea what gun.state() is, but you can have a look in the source code, you should find it in there if it's really a thing
Suleiman Zhukov
@SuleimanZhukov
@rococtz:matrix.org Thank you
Yeah, I found it in the source code in "IGun.d.ts" in gun folder
Omarabuziad
@Omarabuziad
image.png
Hi all , i want to ask why this happened when i use map ,
i have one parent node called messages and it's have 5 child node
when i use gun.get("messages").map(data=>console.log(data)) i expect to log 5 records , but it's console 15 records ?
it's repeating the log as same number of child node properties(here child node has 3 property)
Suleiman Zhukov
@SuleimanZhukov
Guys, quick question, "gun/nts.js" is for animations?
Bo
@worldpeaceenginelabs

@amark @rococtz:matrix.org

One server is enough (assuming you use it with S3 backup), but of course, the more the better. The problem is that there are some performance bugs happening and you can get memory issues when you use more than one.

Could you elaborate please?

Suleiman Zhukov
@SuleimanZhukov
Another question about gun chat:
Should I create a relay server for chat app to work properly?
1 reply
Suleiman Zhukov
@SuleimanZhukov

Is this a BUG????
Another question or this is a BUG:
When I create a user then immediately run command:

gun

It show all nodes with the user, so, user included
Then I refresh the page and run gun command again it doesn't show the user
Even if I link a node to the user and put data in it, it show only if I create chain to it (get(...).get(...).once(...)), but if I run gun command it shows no data, no user, and no nodes
Is this how it should behave and why? Or is it a bug?

And how do I get all the users?
Alex Zanfir
@AlexZan
I am trying to wrap/interface by gunjs map call, to get a list of items, trying to do it using promise.all, but that does not seem to work with gun.map() as expected. Any way to do this?
        return new Promise(resolve => {

            let posts = [];

            const request = gun.get('posts').map(post => {
                console.log('xx-------------------', post)
                posts.push(post)
            })

            //promise all not working with gun.map
            return Promise.all(request).then(
                resolve(posts)
            )
        })
Bradley Matusiak
@bmatusiak
think of map like array.map. then think of on and once as event handlers
so in your case you may want to to ).map().once(
Bradley Matusiak
@bmatusiak
@AlexZan @Omarabuziad ^^
Alex Zanfir
@AlexZan
@bmatusiak thanks for that! but its giving me the same error, TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
Alex Zanfir
@AlexZan
oh disregard, i realized all() requires an array
Alex Zanfir
@AlexZan

okay ive narrowed down the issue now to this

    async post(title, body) {
        console.log('posting ----------------', title, body)
        await gun.get('posts').set({title,body})
        gun.get('posts').map().once(post => console.log('yaaaaaa', post))
    }

for some reason, after setting 'posts', the map.once never iterates, so i dont know if the set is working or not. This is in a jest test environment so i dont know if its something to do with that, or im just missing something simple, since i havent worked with gunjs in years.

Alex Zanfir
@AlexZan
okay seems to work fine in a normal environment, but does not work with jest
Alex Zanfir
@AlexZan
i really need to figure out how to end to end test with gunjs, since im trying to develop using tdd
Mark Nadal
@amark

CHECK OUT WHAT ME AND DAN ( @Draeder ) DID!!!!!!!!!!!!!!
end to end encrypted p2p decentralized live streaming over GUN in 50 lines of code with dynamic resolution
https://twitter.com/marknadal/status/1527374640594595848
soooooooooooo excited. (will catch up with chats later)
1 reply
Syon
@syonfox:matrix.org
[m]
Cool Yeah i had streaming working with gun working sort of it was cool other things have taken priority looks like your is faster and more complete so will most linkly just snag and incorporate it , edit
rococtz
@rococtz:matrix.org
[m]
@SuleimanZhukov: No, it's for time syncing:
https://gun.eco/docs/How-to-Sync-Time
equivalent_log_5626
@equivalent_log_5626:matrix.org
[m]
Can I do this with gun? I want to make a collaborative, crowd-sourced, distributed database of metadata, something like a distributed musicbrainz. When a user changes his metadata the change can be approved by voting on it by the other users, and when changes are approved they propagate to the other databases.
rococtz
@rococtz:matrix.org
[m]
equivalent_log_5626: yes, sounds doable
but I don't think they "propagate" after approval. More likely the other databases would only listen to changes that are marked as approved
Alex Zanfir
@AlexZan
well ive tried cypress, jest/react testing lib, i tried creating a mock localstorage, but no luck, I can not get gunjs working in a testing environment for e2e testing. Any documentation on doing this?
Alex Zanfir
@AlexZan
ive tried setting the storage to file, disabling localStorage, nothing works
just seems like in gunjs in the jest environment is able to set data, since there are no errors, but then when i go to retrieve that same data, there is nothing
setting and getting is done in the same test, so its not a new refence issue
rogowski
@rogowski
so cool @amark and @Draeder . Congrats! Awesome.
Alex Zanfir
@AlexZan

okay i am now trying to get an array of plain objects from my set

  async getPosts() {
    const posts = await gun
      .get("posts")
      .once()
      .map()
      .once(({ title, body }) => {
        return { title, body };
      })
      .then();

    console.log([posts]);
    return [posts];
  }

something like that, but im only getting the one item

Bradley Matusiak
@bmatusiak
Yay!!! WEBRTC. Weeeeeeeeeeeeeeeeeeeeeeeeeeeeee . it's like a fun roller coaster ride using gun now.. bang bank.
Mark Nadal
@amark
@Hr4rjuku grrrmmm... NodeJS not installing on Heroku anymore for GUN, AsyncStorage not working in RN... IDK if I can make it. :( Not sure why those things are failing now. This sucks. I need someone smarter than me to help. Is that you? If not, who here do you think can?
@blwtxc :clap: @bmatusiak yupe browser gives them 60 retries before evicting them. Peer management was one of the poorest tested parts of the code for years, buuuuut! Guess what PANIC tests just got written that now check for this! :) :) :)
@bmatusiak :laughing:
@haveanicedavid:matrix.org :+1: perfect, enjoy your trip. Make sure to ping me (twitter best for scheduling) to join. Indexing is best.
@siegfried browsers only support SHA ( https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#parameters ). Blake is great, do it, but you'll need a WASM one. Good Q.
@SuleimanZhukov :clap: @rococtz:matrix.org :clap: @draeder .
@ashtyn3 @ashtyn3 :clap: :+1: @rococtz:matrix.org .
@zelenskyszebra:matrix.org :zap: :clap: @rococtz:matrix.org . :clap: :clap: :clap: YOU'RE ON FIRE :fire: :fire: :fire:
@Pape666 :clap: @draeder . You got Presence working now?
@ilhamgum :clap: @rococtz:matrix.org :clap: @draeder , tho I don't think create works with pair, but auth does.
@emretufekci won't useEffect refire itself every time a mutation happens? Maybe that is why?
@SuleimanZhukov :clap: @ns7d4hs246:matrix.org , tho note data is also stored in browsers, they back it up - this is the famous demo even just 1 year after starting GUN https://www.youtube.com/watch?v=-i-11T5ZI9o still works to this day: mocha test/panic/holy-grail.js install PANIC tho.
Signatures happen automatically when logged into a user.
@ns7d4hs246:matrix.org :clap: @luciferianink:matrix.org . And wow, saw you started helping people before even saying hi! <3 love it.
@AlexZan :clap: @rococtz:matrix.org . :clap: @bmatusiak . The await probably threw off your test runner (?). PANIC is e2e, usually I have to turn off storage in them, not the other way around. Could be a folder runtime issue? You can't await observable/streams. Why not check for a schema, then resolve a promise once fufilled? That's the best way to do it, we tell people.
@haveanicedavid:matrix.org GUN core no. RAD yes, I want to hand it off anyways, the only things that matter to me is (A) 0 dependencies (B) performance/benchmarks (C) byte size. Those are easy to measure. Are objective.
@rhythnic :wave: :) hi. 'list' only listening to 'list', your put was saving somewhere else that I don't see you have a listener for. Does that help?
@haveanicedavid:matrix.org I thought @draeder replied about ok but now I don't see it?
@SuleimanZhukov :clap: @rococtz:matrix.org . State manages time/vector/etc. :clap: @ilhamgum . (Huh? gun? I think you're looking at the console explorer, that's not how the API works.) :clap: @rococtz:matrix.org
@Omarabuziad try ...map().once(cb) tell me if fixes?
@worldpeaceenginelabs I've heard the browser sometimes gets stuck relaying data for the relays.
@syonfox:matrix.org really!?? :) Would love to see that old demo!!! This one not complete at all, just every year I've been ++performance obsessively (tho, 1 wrong DOM mistake & all the perf is blocked. Sigh. So be careful!)
@equivalent_log_5626:matrix.org :clap: @rococtz:matrix.org . Sounds closer to Iris than "voting".
@zelenskyszebra:matrix.org <3 :)
@haveanicedavid correct, checking for err is more important than ok
Syon
@syonfox:matrix.org
[m]
all my gun stuff ins on https://bullchat.syon.ca that experiment is in a half broken state but it was just dumping webcam data into gun.