Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 24 23:36
    syonfox updated the wiki
  • Sep 23 21:10
    qgustavor commented #1280
  • Sep 23 21:06
    qgustavor commented #1280
  • Sep 23 21:05
    qgustavor commented #1280
  • Sep 23 20:57
    qgustavor commented #1280
  • Sep 23 20:40
    draeder commented #1282
  • Sep 23 20:38
    draeder commented #1280
  • Sep 23 20:36
    draeder commented #1283
  • Sep 23 10:21
    Codzaa opened #1283
  • Sep 23 02:25
    qgustavor commented #1280
  • Sep 21 09:26
    mmalmi opened #1282
  • Sep 19 21:08
    thiago-hs closed #1281
  • Sep 19 19:48
    thiago-hs edited #1281
  • Sep 19 19:33
    thiago-hs edited #1281
  • Sep 19 19:33
    thiago-hs opened #1281
  • Sep 18 20:15
    qgustavor opened #1280
  • Sep 15 05:02
    Alengeorge-01 edited #1279
  • Sep 13 21:32
    csharpner updated the wiki
  • Sep 13 08:12
    Alengeorge-01 opened #1279
  • Sep 12 13:13
    1MaddieX updated the wiki
Daniel Raeder
@draeder
@DevSalmon2_twitter React has some real weird edge-cases with Gun..
Mark Nadal
@amark
@leoncstew they share the same object constructor so GUN({store: {put: ..., get: ...}
@AlexZan @computervillain_twitter @adam_blvck:matrix.org :clap: @rococtz:matrix.org . It'll do it faster than __, but yeah :clap: @dev1n:matrix.org definitely choose https://github.com/gundb/interop/blob/main/webtorrent/index.html instead, or some other real tech, not the slow junk.
@verschmelzen:matrix.org did you watch the 30min https://gun.eco/docs/Porting-GUN ? @ is ACK, # is msg ID, ok means no error. A new thing (as of this last couple months) is we're officially supporting "hijacking" ACK/OK responses with custom data / behavior, which is how the WebRTC module is generating its SDP negotiation handshake as a RPCed state machine. But as far as GUN / wire, its just ACK / ID / OK. It doesn't know any better.
@champ5898 :clap: @draeder - we're unable to prevent websocket errors from logging tho, that is at the Browser level. @champ5898 are you using AXE? It's undergoing a lot of changes right now. Do you need it? You could turn it off and manually add your own peers.
Can people please remind the Discord server that I'm banned and nobody should be using Discord unless they want to hide from me?
@DevSalmon2_twitter :clap: @dev1n:matrix.org , are you on v0.2020.1238? If not, please upgrade & try again.
@dev1n:matrix.org :clap: @jabis . (Tho did I miss something? Did gitter not load something?). I have no clue how TS works, glad there are others who do.
Yes, as a mathematician, they call all my variables o, t etc. as if I'm a human minifier. But it works, super fast speed, 10K ops/sec on 2015 Air!
@verschmelzen:matrix.org GUN uses the in & out events to message things, while as DAM uses mesh.say(data, peer) and hear things. onto is my event listener/emitter library - its faster than everything else I tested because it does direct function calls rather than using a delegator.
@azdez:matrix.org :+1: @draeder . Willing to donate time adding tests to Book so we can feel safe/confident publishing the new RAD that uses it?
1 reply
Mark Nadal
@amark
@ahg:it-dengler.de ROFL PetiteVue is syncing with GUN without any calls??? How is that possible? If so, sounds like a feature, not a bug?
@acblackburn :clap: @adam_blvck:matrix.org . S3 on v0.2020.1238, or an older one?
@mmalmi did you see the thing about needing api.rs or something in flutter for @VittorioParagallo ? ( @tylerjwatson how's your Rusting going?)
I feel like we should be able to have "only save my friend's data" based-on-pubkey feature in about ~9sh months.
1 reply
voidwalker09
@voidwalker09:matrix.org
[m]
Hi. Can I use gun instead of orbitdb to have a simple key:value store that is mutable ? Does it have http or other kind of api so I can use from a non-js code base?
Mark Nadal
@amark
@voidwalker09:matrix.org it'll be much faster too. There is not an HTTP API built in (that would make it centralized) but I believe @noctrisa @bresnow &https://github.com/lmangani/gunstore.io and a few others have made different/separate modules for that @draeder remember any others? (its pretty easy)
people often don't, because GUN has realtime features - and once you use them, its hard to go back.
voidwalker09
@voidwalker09:matrix.org
[m]
I do not understand how adding a HTTP API control interface would make it centralized ? or gRPC. It
It's just a way of programatically interacting with any other programming language.
verschmelzen
@verschmelzen:matrix.org
[m]

Also I plan to add gun instance override for webrtc.js later so that only people in room (and sharing rooms key) could see the messages. For example pass gunsafe instance to webrtc.js instead of usual gun instance to start communication.

Not sure if that will be useful in upstream, but I will use it for my project

noor aldeen
@nour-dev
hi, how to run gun in node.js peer ?
2 replies
ALEN GEORGE
@alen_george_gitlab
Hi, Does anyone know how we can make gun SSR support?
Daniel Raeder
@draeder
@alen_george_gitlab We are working on scalable source routing .. https://twitter.com/marknadal/status/1557897882988007424
1 reply
ALEN GEORGE
@alen_george_gitlab
Hi, Does anyone know how we can make gun SSR (Server side rendering) support?
CeNiEi
@ceniei:matrix.org
[m]

hi folks!
I am trying to make a react chat application using Gun. I have the following code which is fetching the messages.

  const fetchMess = useCallback((key) => {
    const messages = gun.get(key);
    messages.map().on((m) => {
      console.log(m);
      dispatch({
        type: "add",
        newMessage: {
          name: m.name,
          message: m.message,
          createdAt: m.date,
          key: m.key,
        },
      });
    });
  }, []);

For some reason, the callback for on is being fired multiple times for every message, the first time I am calling this function. This is messing up the message list, since the dispatch (responsible for changing the state of the message list; from the useReducer hook) is mutating the message list multiple times.

Any work around for this?

Jabis Sevon
@jabis
@ceniei:matrix.org use some schema enforcing, and function debouncing within a set time period to avoid multiple dispatches
gun is reactive by default - you're gathering objects from multiple sources with some input lag, something simple like ajv can give you an easy first step - if schema doesn't match just return from the callback, without ajv lib bloat you could just use simple if(!m || !m.prop1 || !m.prop2 || !m.prop3) return;or whatever you need to before the dispatch
Jabis Sevon
@jabis
@ceniei:matrix.org for completeness
a debouncing fn would look roughly something like this:
function debounce(func, timeout = 300){
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => { func.apply(this, args); }, timeout);
  };
}

function dispatch(x){
  console.log(`Processing data ${x}`);
}

const dispatchDebounced= debounce((...args) => dispatch(args));
for(x=10000;x>0;x--){
    dispatchDebounced(x) // you should see in console only 'Processing data 1' instead of 10000 :)
}
Jabis Sevon
@jabis
do note that debouncing is when you care about the last update, while "schema matching" lets it run whenever you have a record with full data
but there a couple of utilities for further mischief :)
verschmelzen
@verschmelzen:matrix.org
[m]
Hey. I stumbled upon this thing https://replicache.dev/. Looks like they are trying to solve the same problem as gun. But their github is empty 🤔. @amark wdyt?
Their performance claims - https://doc.replicache.dev/performance
Also I see top project in github offline-first group starting to appear between 2014-2017. Interesting if there is an ongoing trend of web apps moving to offline-first and p2p 🤔
1 reply
tedd pasta
@azdez:matrix.org
[m]

@draeder: do you mean that Book returning a page and a half is working or the lexical part is working. because i tried a lexical query and it is not returning each object.

gun.get('tests').get({'.': {'>': 'a', '<': 'z'}, '%': 50000}).once().map().once((datas) => {
  console.log(datas)
})

the above returns nothing even though it should

i don't know why but this works.

gun.get('tests').get({'.': {'>': 'a', '<': 'z'}, '%': 50000}).once(data => console.log(Boolean(data))).map().once((datas) => {
  console.log(datas)
})

if i console log the first once() for some reason it returns each object/data by itself on the second once() after the map()

tedd pasta
@azdez:matrix.org
[m]
lex queries are not working as it should. strange, wasn't working before but now it's working. well that takes care of that.
ALEN GEORGE
@alen_george_gitlab

Hi does anyone know why I'm getting this error in angular after creating a new user using Gun?


UnhandledPromise rejection: Unexpected non-whitespace character after JSON at position 2 ; Zone: <root> ; Task: null ; Value: SyntaxError: Unexpected non-whitespace character after JSON at position 2

The code gives me an error at sea.js file. And it looks like this.


 // ideally we can move away from JSON entirely? unlikely due to compatibility issues... oh well.
        JSON.parseAsync = JSON.parseAsync || function(t, cb, r) {
            var u;
            try {
                cb(u, JSON.parse(t, r))
            } catch (e) {
                cb(e)
            }
        }

Can anyone help me with this ?

6 replies
RamiMetry
@RamiMetry
hello i am trying to integrate Gunjs in my react native mobile app
when i use gun.get() the result is always undefined
2 replies
any help please
Capture.PNG
i already tried to put await and Promise.all and tried a call back function
the all work in react js but in react native console.log (a) is always undefined
Sascha1337
@sascha1337:matrix.org
[m]
$GUNFTW
Jabis Sevon
@jabis
@RamiMetry gun is not promisified, you'll need either gun/lib/then.js or gun/lib/promise.js to have the reactive chain working with promises - see the source of the extensions for more usage tips
Jabis Sevon
@jabis
or you can wrap your own - here some pseudo code, but do note that the most fun part about gun is the reactiveness :)
Gun.chain.promGet = function(key) { let chain = this; return new Promise(resolve=>{ chain.get(key).once(resolve) }) }

// usage after instantiating : let gun = Gun({...})
//either with async
(async()=>{
let results = await gun.get("myapp").promGet("key")
console.log("results",results)
})()
// or with regular promise-then
gun.get("myapp").promGet("key").then(results=>
  console.log(results);
})
Jabis Sevon
@jabis
First results recovered from .once might be incomplete depending on your peers, so you might have to replay it
1 reply
lightningx10
@lightningx10
Hey all, just wondering how NTS actually works? On the page for NTS, it says that server nodes do not obey NTS. This is fine and all, but I have a node relay running and my clients both have a different local time, the clients have a delay between receiving messages because the relay doesn't accept the message until its time has caught up. (relay running in a VM with a slow clock I think). It also says that they're meant to "catch up" or "resolve" with the node, but I don't see the clocks changing (I'm running the ntp example, with and without a sync to this node and either way it's the same time)
clararussell
@clararussell:matrix.org
[m]
This message was deleted
1 reply
RamiMetry
@RamiMetry
Capture.PNG
hello guys I have founded the issue but it is a new problem the import of gun in my react native app is not working
in this picture when I console log gun i get undefined
I already yarn add gun
and i tried the same way in react js it works normally but in react native the response is always undefined
any idea how can I fix it please
1 reply
and i am sure my relay server is working properly because it works in react js
11 replies
dev1n
@dev1n:matrix.org
[m]
Is there a way to stop gun once it's instantiated?
Meaning, force it to close peer connections.
My use case is low powered devices which would need to sync only temporarily, then disconnect, to conserve battery.
rococtz
@rococtz:matrix.org
[m]
dev1n: That doesn't sound like it has to do anything with Gun. Why not have a cron job to start the process and kill it?
it's just a node process
1 reply
Daniel Raeder
@draeder
@dev1n:matrix.org gun.get('someApp').get('someTopic').off()
2 replies