Created
March 4, 2018 12:11
-
-
Save meteozond/03e689111a508341c2f966d7100457cb to your computer and use it in GitHub Desktop.
Hackish workaround for app-framework & vue-idb $db clashing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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