Skip to content

The vue plugin that attaches electron-json-storage APIs to the Vue object, making them accessible to all components.

License

Notifications You must be signed in to change notification settings

admbradford/vue-electron-json-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-electron-storage

A vue plugin that wraps electron-json-storage APIs to the Vue object.

js-standard-style

Installing

Install using NPM

npm install vue-electron-json-storage --save

Include using webpack or browserify

main.js

import Vue from 'vue'
import VueElectronJSONStorage from 'vue-electron-json-storage'

Vue.use(VueElectronJSONStorage)

Using the plugin

This plugin will attach electron-json-storage APIs to the Vue object itself, so accessing all APIs is dead simple. All official documentation from electron-json-storage can be used and accessed from this.$storage.

So instead of...

const storage = require('electron-json-storage')

export default {
  methods: {
    getName () {
      storage.get('name', (err, data) => {
        if (err) {
          console.error(err)
        } else {
          console.log(data)
        }
      })
    }
  }
}

Now you can...

export default {
  methods: {
    getName () {
      this.$storage.get('name', (err, data) => {
        if (err) {
          console.error(err)
        } else {
          console.log(data)
        }
      })
    }
  }
}

Now you might be thinking, "Is it really that annoying to simply require electron to access it?" Probably not, but it can get cumbersome to have to include it in every component file that needs it. In the end, attaching electron-json-storage directly to Vue just makes sense.

About

The vue plugin that attaches electron-json-storage APIs to the Vue object, making them accessible to all components.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published