Skip to content

Instantly share code, notes, and snippets.

@meteozond meteozond/vue.js
Created Mar 4, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.