Skip to content

Instantly share code, notes, and snippets.

@meteozond
Created March 4, 2018 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meteozond/03e689111a508341c2f966d7100457cb to your computer and use it in GitHub Desktop.
Save meteozond/03e689111a508341c2f966d7100457cb to your computer and use it in GitHub Desktop.
Hackish workaround for app-framework & vue-idb $db clashing
import Vue from 'vue'
import VueIdb from 'vue-idb'
module.exports = (vue) => {
// Defining $db property as configurable
Object.defineProperty(Vue.prototype, '$db', {
get() {
// eslint no-underscore-dangle: ["error", { "allow": ["_db"] }]
return VueIdb.$dbValue
},
set(value){
VueIdb.$dbValue = value
},
configurable: true
})
// Initializing vue-idb
Vue.use(VueIdb)
// Binding vue-idb to $idb propert
Object.defineProperty(Vue.prototype, '$idb', {
get() {
/* eslint no-underscore-dangle: ["error", { "allow": ["_db"] }] */
return VueIdb._db
}
})
const idb = new VueIdb({
version: 1,
database: 'test',
schemas: [
{ tests: 'id, title, created_at, updated_at' },
{ posts: 'id, owner' },
],
})
vue.mixin({
idb,
})
return vue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment