Skip to content

Instantly share code, notes, and snippets.

@bioshazard
Last active November 29, 2020 04:08
Show Gist options
  • Save bioshazard/deca0a65e3e42997809cd738c86490f6 to your computer and use it in GitHub Desktop.
Save bioshazard/deca0a65e3e42997809cd738c86490f6 to your computer and use it in GitHub Desktop.

GunDB VueJS Notes

vue-gun

// Initialize gun
import Gun from 'gun'
// localStorage.clear()
var gun = new Gun(['https://mypeer.hostname:8765/gun'])

import VueGun from 'vue-gun';
Vue.use(VueGun, { gun: gun });

Usage in component method:

var newSourceNode = this.$gun.get(this.$uuid.v4()).put({src:"http://asdf.com"})

Vue Prototype

var zkgun = {
	gun: null, // must be initialized
	setGun: function(gun) {
		this.gun = gun
	},
  ...

Init:

// My Gun Lib
import zkgun from './lib/zkgun.js'
zkgun.setGun(gun)
Vue.prototype.zkgun = zkgun

Usage in component method:

var newSourceNode = this.zkgun.get(this.$uuid.v4()).put(this.newSource)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment