Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sjones6/vue-gun
A Vue plugin to add Gun integration
https://github.com/sjones6/vue-gun
Last synced: 3 months ago
JSON representation
A Vue plugin to add Gun integration
- Host: GitHub
- URL: https://github.com/sjones6/vue-gun
- Owner: sjones6
- Created: 2017-04-09T01:43:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-17T15:59:31.000Z (over 6 years ago)
- Last Synced: 2024-07-21T11:02:50.731Z (4 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 89
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - sjones6/vue-gun - A Vue plugin to add Gun integration (others)
README
# Vue-Gun
A plugin to make Gun integration with Vue easier.
## Installation
`npm install vue-gun --save` or `yarn add vue-gun`.
Add the plugin:
```javascript
import VueGun from 'vue-gun';
Vue.use(VueGun, {
gun: gun // your gun instance
});
```## Initialize Gun
You can either pass in a `gun` instance fully initialized, or allow VueGun to initialize it for you:
```javascript
import VueGun from 'vue-gun';
import SEA from 'gun/sea'; // Required for SEA functions and user authentication
Vue.use(VueGun, {
gun: gun // must be passed in at `gun` key
});
```Allow VueGun to handle initialization by passing in options:
```javascript
import VueGun from 'vue-gun';
Vue.use(VueGun, {
peers: ['someurl.com:9000/gun']
});
```## Usage
Access the `gun` instance with `this.$gun` inside of your Vue instance and components.
For instance inside your component, you might have this:
```javascript
mounted: function() {
this.$gun.get('some path').map().on((node, key) => {// add results straight to the Vue component state
// and get updates when nodes are updated by GUN
this.vueState[key] = node;
});
},
```