Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 05 10:50
    davidmaxwaterman commented #636
  • Oct 05 09:25
    worldpeaceenginelabs updated the wiki
  • Oct 04 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
watermelonglacier
@watermelonglacier
This message was deleted
2 replies
Lexi
@Lexi:matrix.org
[m]
@estebanrfp: hello, I have a question and I'm mentioning you because you developed the website for GUN, right? I can't select the text in the HTML list on https://gun.eco/docs/SEA.certify#policy on my android device. Can you reproduce this?
Hope you have a great day :-)
Cristian Sfetcu
@freewill777
Hello gunners :) I can't sync 2 instances of the app across LAN

I just copied the Thoughts App (gun lib loaded from cdn) - it works well if I test it on multiple browsers on same machine. If I want to access the app from other machine in the same LAN, i see the app but I don't see the already existing data, I see it as a new instance of the app. I might be doing something wrong..?

I serve a static index.html document with VS Code Live Server

<html>

<body>
    <h1>Thoughts</h1>

    <form>
        <input><button>Add</button>
    </form>

    <ul></ul>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/gun@0.2020.1233/gun.js"></script>
    <script>
        var gun = Gun().get('thoughts');
        $('form').on('submit', function (event) {
            event.preventDefault();
            gun.set($('input').val());
            $('input').val("");
        });
        gun.map().on(function (thought, id) {
            var li = $('#' + id).get(0) || $('<li>').attr('id', id).appendTo('ul');
            if (thought) {
                $(li).text(thought);
            } else {
                $(li).hide();
            }
        });
        $('body').on('dblclick', 'li', function (event) {
            gun.get(this.id).put(null);
        });
    </script>
</body>

</html>
Cristian Sfetcu
@freewill777
also have put this on a web hosting
Cristian Sfetcu
@freewill777
and everyone logging in seems to have its own list
Bo
@worldpeaceenginelabs

@freewill777 maybe i am wrong, but seems like there is no relay you syncing the clients with???
looks like every client saves locally, inside its own Gun instance. but i am a beginner could be bs πŸ˜…

but usually you initialize the relay with something like this.

var gun = Gun({
  web: server,
  peers: ['https://relayname.providername.com/gun']
})
3 replies
Bo
@worldpeaceenginelabs
your code should sync locally(inside your LAN 192.168....), but the webhosting version will be like "every client for itself" (or a local database) without a Gun relay.
3 replies
Bo
@worldpeaceenginelabs
you could also run a desktop relay https://github.com/worldpeaceenginelabs/ELECTRON-GUN and replace server.js with the above script. than you can add it with peers: https://localhost:8080/gun or maybe without /gun to your client's code.
if you use a free https://www.noip.com account and download their client (all os available) your web hosted clients can reach your desktop via https://yourname.noip.com/gun (or without /gun)
its a cool setup for testing things out. if everything works, you can add production ready gun relays (desktop/hosted) any time. (without having to change your code, except peers: of course
Mark Nadal
@amark
Sorry all! Like I've been saying, super spotty lately, especially without my laptop. Good news, I'll have it back next week! But then won't be home for a few weeks.
In other news
It's my πŸŽ‚ birthday today
3 replies
All I ask is you take my twitter poll https://twitter.com/marknadal/status/1577112069945511936 and β™₯ help share it!
soulofmischief
@soulofmischief
Happy birthday @amark !!! Hope it's a great one!
Bo
@worldpeaceengine:matrix.org
[m]
@amark: Happy Birthday Mark!!! πŸ₯³
Bo
@worldpeaceenginelabs

@freewill777 i updated the gun desktop relay with the snippet from the Gun Wiki and renamed server.js to server.mjs and updated main.js (to make use of electron is actually very easy with this template, you could literally add anything to server.mjs and it becomes a desktop app) https://github.com/worldpeaceenginelabs/ELECTRON-GUN (ready to go) ;)

If i like to play around with it, i just start the electron gun in a console or run the compiled electron exe file. my clients have an entry peers: https://...relay.ddns.net which connects to my electron gun on my notebook.

Max Waterman
@davidmaxwaterman
Hello. It's taking me longer than 5 minutes, and I'm invited to ask for help. I'm trying to get started with gun in a browser extension background script.
  1. The first problem I have is trying to import gun into my es6 jsm...import * as Gun from "./node_modules/gun/gun.js" seems to get rid of the errors of my previous attempts, but then Gun is not a function.
  2. To side-step the above, I loaded gun.js using a script tag in the background-page, so I can then use window.Gun(). I have another laptop on the lan and on which I intend to run a server - I used the docker run option to do that, and I can telnet/nc to it and GET / resulting in some html file - so connectivity is ok. However, in my background-script, it results in Firefox can’t establish a connection to the server at wss://192.168.0.115:8765/ (or ws://... if I specify http instead...though I also get a '400' response for that).
    Clearly, I am missing something fundamental. I'd appreciate any pointers to help me along.
    (oh, and happy birthday @amark :) )
6 replies
ProjectX1989
@ProjectX1989

`<script>
import GUN from "gun";
import { onMount } from 'svelte';
export const db = GUN(['http://localhost:5173/gun']);

let kitchenOutput = {};

onMount(() =>{
    db.get("count").map().once(
    async (data, id) => {
        console.log("CHANGED");
        kitchenOutput = data;
    }
);
})

let count = 0;

function onClick() {
    count++;
    console.log("CLICKED " + count);
    db.get("count").set({"clicked":{count}});
}

</script>

<h1>{JSON.stringify(kitchenOutput, null, 2)}</h1>

<button on:click|preventDefault={onClick}> CLICK ME </button>`

Hi all. I'm not sure what I've done wrong but when I run two clients on localhost it doesn't sync the clients automatically.

Any help is appreciated
Lexi
@Lexi:matrix.org
[m]

@ProjectX1989: hello, welcome to the chatroom. I recommend trying to get it to work with only JavaScript first and if that works try to add Svelte.

Any errors in the console?

4 replies
Bo
@worldpeaceenginelabs

@Lexi:matrix.org @ProjectX1989 There is no Svelte to remove or add ;)
The only difference to JS ( or a framework like React) in the snippet is Svelte's onMount, which is the pendant of useeffect in, for instance, React. The rest is just JS.

  1. I would change line 4 from "export const db..." to "let db..." (i think a const (one time init) is not the right variable type for the use case of the Gun variable. (which's content changes constantly) And export(the way its used in Svelte) seems also wrong, but maybe your use case is different) So one of this two could have caused the bug.

  2. http://localhost:5173/gun is this the address from a Gun relay running seperatly from the two clients? So three actors, relay, client, client? (stupid question maybe, but just to make sure)

1 reply
Emeduduna Akerejola
@Emedudu
Gun is so freaking persistent
What is the difference between set and put please?
2 replies
Max Waterman
@davidmaxwaterman
How can I start from scratch?
14 replies
Max Waterman
@davidmaxwaterman
Were can I find the val() function? https://www.youtube.com/watch?v=k-CkP43-uJo
2 replies
Lexi
@Lexi:matrix.org
[m]
But before letting them connect again. Otherwise they'll share data again
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
What is Invalid data: Array at l8x6jzuqmR7WtU5183g9.temp0 trying to tell me?
1 reply
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
Another one is: Invalid data: undefined at bookmarks... - I guess it can't handle properties that are 'undefined'?
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
It opened in a browser tab, not in the PWA :/
but I'm here now, so all good, I think.
Is it because it's an Array? I found some github issues on handling Arrays, rather than Objects...
Lexi
@Lexi:matrix.org
[m]
Yeah, GUN does not allow saving arrays. Use objects instead https://github.com/amark/gun/wiki/Snippets#saving-arrays-in-gun
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
I made my own reducer, since I think it would be easier to access via another property in each array item anyway (they all have an 'id' property). That seems to do something...though I'm not entirely sure.
I find I have to do once(x => console.log(x) to find out if what I am 'get()'ing is the right thing.
Ah, this bit of your snippet is interesting: delete data._; -> so that is some gun bookkeeping ....and load looks useful too :)
Lexi
@Lexi:matrix.org
[m]
once(console.log) is a little shorter if that helps
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
It's ok...just want to know if that's the correct thing to be doing...
Lexi
@Lexi:matrix.org
[m]
If you just want to log the data to the console, sure! You're missing the key though, but you might not be interested in it, I don't know :-)
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
yeah, I've done (v,k) => console.log(k,v) previously...
but how does this differ to just doing a get()?
Lexi
@Lexi:matrix.org
[m]
get() is for writing a query. GUN needs the path you're trying to query/get. Then afterwards you tell GUN to put, set, map, on or once etc.
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
OK.
Is path() still a thing, or it is preferring to chain get()s?
Lexi
@Lexi:matrix.org
[m]
Haven't seen anyone use path() nor have I used it myself. You can read about it here: https://gun.eco/docs/API
davidmaxwaterman
@davidmaxwaterman:mozilla.org
[m]
Yeah, that's where I found it :)
I noticed a comment there that says 'you probably shouldn't be using it'...
Anyway, I'll take your hint and use chained get()s instead.
Esteban Fuster Pozzi
@estebanrfp
@Lexi:matrix.org + thanks for helping to improve the documentation application, try to clean the cache and confirm if it works correctly
1 reply
image.png