JvSomeren / vue-peerjs

MIT License
14 stars 4 forks source link

Util Object? #9

Closed nebucaz closed 3 years ago

nebucaz commented 3 years ago

How can we access peer's util object from Vue? As far as I can see, it's not exported.

JvSomeren commented 3 years ago

I believe you are right about that. I found this issue in the PeerJS repo.

It suggests using window.peerjs.util or just peerjs.util.

nebucaz commented 3 years ago

Thanks for the suggestion, but none of them seem to work. Would it be possible to expose it explicitly in vue-peer/src/index.js (sorry, I'm not familiar with creating Vue/NPM Modules, just an idea).

export default {
  install(Vue, peer, options) {
    if (!isPeerJS(peer)) {
      throw new Error('[vue-peerjs] you have to pass a 'Peer' instance to the plugin');
    }

    Observe(peer, options);
    // eslint-disable-next-line no-param-reassign
    Vue.prototype.$peer = peer;

--> here 
  }
JvSomeren commented 3 years ago

This package is just a wrapper around peerjs. So it's unable to import (and thus expose) the util object for the same reasons you are. I'm sorry about that.

nebucaz commented 3 years ago

Second try: console.log(window.peerjs.util.browser);

now seems to work. Thanks