DeFUCC / gun-vue

Vue + Gun = reactive p2p crypto graph app toolkit. Vue 3 composables and components, a relay server, a demo app and more!
http://gun-vue.js.org/
77 stars 20 forks source link

Error in doc: useRelay doesn't support "host" argument #11

Closed Extarys closed 2 years ago

Extarys commented 2 years ago

See the documentation here:

image

And the useRelay function here.

When I try to get the server's status, it always gives me the demo server:

{ "peer": "https://etogun.glitch.me/gun", "host": "etogun.glitch.me", "status": "offline", "started": 0, "pulse": 0, "lag": 0, "diff": 0, "age": "0ms", "delay": 1646331513100, "blink": false }

I'm still figuring everything out, with Nuxt 3 I finally was able to get something with your suggestion thanks!

const comp = shallowRef(null)

onMounted(() => {
  import('@gun-vue/composables').then(module => {
      console.log(module)    
      comp.value = module?.useRelay("http://localhost:4200/gun")
  })
})
davay42 commented 2 years ago

If you want to use your relay, you need to set it like this:

import { useRelay } from '@gun-vue/composables'
const relay = useRelay()
relay.setPeer('http://0.0.0.0')

This save the url to the localstorage and reload the page, so you'll have all gun instances in sync with the new relay.