Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Error: cannot redefine property: $events #15

Open
acacha opened this issue Nov 4, 2017 · 2 comments
Open

Error: cannot redefine property: $events #15

acacha opened this issue Nov 4, 2017 · 2 comments

Comments

@acacha
Copy link

acacha commented Nov 4, 2017

If I use this package in 2 different libraries and then use this 2 librares in another one then thw following problem occurs:

index.js:104 Uncaught TypeError: Cannot redefine property: $events
    at Function.defineProperty (<anonymous>)
    at plugin (index.js:104)
    at Function.Vue.use (vue.common.js:4618)
    at Object.disposed (index.js:148)
    at __webpack_require__ (bootstrap 7ecffedbdf2f7047c51d:19)
    at Object.disposed (forge-bootstrap.js:1)
    at __webpack_require__ (bootstrap 7ecffedbdf2f7047c51d:19)
    at Object.<anonymous> (app.js:18)
    at __webpack_require__ (bootstrap 7ecffedbdf2f7047c51d:19)
    at Object.<anonymous> (app.js:25575)

Any clue how can I solve this problem?

@acacha
Copy link
Author

acacha commented Nov 5, 2017

I can avoid this problem using:

// Extend `Vue.prototype` to include our global event bus.
  if (! Vue.prototype.hasOwnProperty('$events')) {
    Object.defineProperty(Vue.prototype, '$events', {
      get: function get() {
        return events;
      }
    });
  }

When defining $events property. Do you want I create a PR?
But reading the code ti seems to me that this is a Bug related with:

  if (plugin.installed) return

Maybe only works with vue 1?

@cklmercer
Copy link
Owner

Feel free to PR the code change from above. I'll take a look and make sure everything is square before publishing a new version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants