Skip to content

Commit

Permalink
fix: resolves vuex-orm#544, resolves vuex-orm#548
Browse files Browse the repository at this point in the history
  • Loading branch information
cuebit committed Feb 4, 2020
1 parent f6ef777 commit 2ae995d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/database/Database.ts
Expand Up @@ -189,9 +189,24 @@ export default class Database {
private createBindingModel (model: typeof Model): typeof Model {
const database = this

const c = class extends model {
static store (): Store<any> {
return database.store
let c: typeof Model

// When utilising code targeted at ES5 mixed with code targeted at ES6
// causes a runtime error when using mixin classes.
// Nuxt.js is a good example edge-case.
try {
c = Function('model', 'database', `
return class extends model {
static store () {
return database.store
}
}
`)(model, database) as typeof Model
} catch {
c = class extends model {
static store (): Store<any> {
return database.store
}
}
}

Expand Down

1 comment on commit 2ae995d

@cuebit
Copy link
Owner Author

@cuebit cuebit commented on 2ae995d Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently passes initial tests but requires exercising coverage.

Please sign in to comment.