Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:29
    soulofmischief updated the wiki
  • Oct 03 16:40
    DvilDmonPsyAres edited #1284
  • Oct 03 16:39
    DvilDmonPsyAres edited #1284
  • Oct 03 16:38
    DvilDmonPsyAres opened #1284
  • Oct 03 09:16
    expelledboy commented #1277
  • Sep 30 03:31
    Alengeorge-01 commented #1279
  • Sep 29 21:58
    draeder commented #1279
  • Sep 29 21:55
    draeder commented #1279
  • Sep 28 07:58
    mmalmi commented #1282
  • Sep 28 04:07
    Alengeorge-01 commented #1279
  • Sep 28 04:07
    Alengeorge-01 commented #1279
  • Sep 28 04:06
    Alengeorge-01 commented #1279
  • Sep 27 23:41
    amark closed #1283
  • Sep 27 23:41
    amark commented #1283
  • Sep 27 23:39
    amark commented #1280
  • Sep 27 23:25
    amark edited #1279
  • Sep 27 23:24
    amark commented #1279
  • Sep 27 23:21
    amark closed #1273
  • Sep 27 23:21
    amark commented #1273
  • Sep 27 23:16
    amark commented #1271
dev1n
@dev1n:matrix.org
[m]
The factory function code is:
function userFactory() {
 const user = gun.user()
  return new Promise(resolve => {
    gun.on('auth', () =>{
      console.log(user.get); // fine
      resolve(user);
    });
  });
}
Client function code:
userFactory().then(user => {
  console.log(user.get); // undefined
})
22 replies
DevSalmon
@DevSalmon2_twitter
dev1n
@dev1n:matrix.org
[m]
I believe you but I haven't seen anything like that in the recent years, I would be surprised if this is what I'm hitting in this case.
Jabis Sevon
@jabis
It's not your root cause, but as I said, you're setting up the promise incorrectly, to an event which might never get called, thus your chain remains empty on the .get part as it's actually not resolved
I just noted that I've ran into these weird const issues when dealing with JS prototypal inheritance (chains) earlier, so you might be wise to test :)
dev1n
@dev1n:matrix.org
[m]
If I return user directly (not in a promise), then there is no problem either. I will investigate more later, the problem might be in the framework and not gun.
Jabis Sevon
@jabis
promises change the this property so it might just destroy the binding
this usually being window or global but within gun chain it should be the gun instance
dev1n
@dev1n:matrix.org
[m]
I mean I made a test class with regular properties and methods and it wasn't broken.
Jabis Sevon
@jabis
a test class means zero - you have to look at how gun is constructed :)
2 replies
a lot of pre ES5 stuff happening
especially in the chaining functions
so context switch from window(.Gun) to Promise where you're trying to invoke the reactive gun.on listener easily can lose the actual context
Mark Nadal
@amark
@joshbenaron https://github.com/brysgo/graphql-gun ! Tho it needs to be upgraded to latest version (anyone want to help? I can do a screencall).
@adam_blvck:matrix.org :+1: .
@scorezeny:matrix.org :clap: yay Martti!
@agursoy :clap: @Lexi:matrix.org @alterx @draeder . If you can get them to all connect to the same WiFi network, you can run it all locally! (tho be prepared to deal with SSL certs & junk problems like that).
Meething team has done Audio, so it works, its just that its not easy (requires manually appending buffers, different support in Safari, etc.) without "hiccups".
@draeder :clap: @i001962:matrix.org !
@verschmelzen:matrix.org WebRTC SDPs are mystical, eh? :P I'm shocked I could compress it into such a few lines - were you able to figure it out? GUN might start to confuse your video/audio channels tho, thinking they're valid DAM peers. No? Were you able to get it to work?
@tf2_pyro:matrix.thisisjoes.site :clap: @rococtz:matrix.org . :fire: ;) GUN is smart, glad you like. :clap: @Lexi:matrix.org . Gonna get even smarter with Book's "nearest data pages" too! Hopefully within 6 to 9 months?
@timsim00 :clap: @draeder . & Iris - but its code base is deep. Also, check out @nsreed 's "multiplayer whiteboard with ACL" demo & ask for code link ( https://twitter.com/marknadal/status/1552740681554092033 ).
@mikelun :clap: @Lexi:matrix.org :clap: @alterx . Yes .put( is dumb simple, .set( is a convenience wrapper that covers 2+ "array-like" edge cases: Loosely-Ordered Appends & Mathematical Sets (tables), but likewise, requires more understanding to use / checking docs. I'd love if this could be simplified, but like with ACLs, the nature of these things in any system (centralized or not) have nuances to them. Honestly, that is why I prefer more key/value object stores: they're pretty dumb simple & predictable to use.
@leoncstew :clap: @draeder . RAD is gonna get major update with Book power - so if you're willing, would love help there (and note, meanwhile, RAD is not updated to latest GUN so there are quite a few issues presently).
@acblackburn lovely use case! Correct. 2 things to be aware of / help you out: (A) just put(formData) not put({data: formData}), (B) doing .put(null) nulls out the LINK to the data (GUN is a graph database), it doesn't null the data itself, unless (C) you serialize your formData as a string? (maybe a bad idea), then when you do .put("the form data") and later .put(null) the null overwrites the bytes of the previous string/text, because the data was saved in-place not as a link to another data node.
... still catching up ... will continue more later ...
1 reply
verschmelzen
@verschmelzen:matrix.org
[m]
I guess I have found root.on source code, but I have no idea what happens here 🤷
tedd pasta
@azdez:matrix.org
[m]
is lexical queries fixed yet? i remember trying to paginate and the lex queries did not work as it should have.
DevSalmon
@DevSalmon2_twitter
Hey guys, sorry for this seemingly silly question, but auth on different devices doesn’t seem to work unless I spam sign in, related to https://stackoverflow.com/questions/69070363/gunjs-user-not-getting-authenticated-in-incognito-window. Am I missing something?
Daniel Raeder
@draeder
@azdez:matrix.org I don't think so..Gun's DHT has taken priority, making a lot of progress (incremental though!) with @amark
4 replies
DevSalmon
@DevSalmon2_twitter
Thanks!
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