Electron-vue: peerjs(webrtc) / vuejs

Created on 3 Apr 2017  ·  2Comments  ·  Source: SimulatedGREG/electron-vue

Found an issue or bug? Tell me all about!

Hello,
I currently have a problem when I try to add a library (peerjs) it's not a bug, it's for sure a lack of experience of my part.
I wanna declare globaly my peerjs , and call it from anywhere , and i really don't know how to do it :/

How can I reproduce this problem?

npm install peerjs --save
in main.js i added : import Peer from 'peerjs' and below Vue.use(Peer)
in my custom component i tryed with this.$Peer('id', {key:'valueofmykey'}) and many other combinations but have that error : Uncaught ReferenceError: Peer is not defined

Someone can help ?
Thx

Most helpful comment

@Mistes974

Just as @re-fort stated, peerjs alone is not a Vue plugin and cannot be installed directly. To use peerjs in your JS files, simply import it and use it directly. For example...

main.js

// import
import Peer from 'peerjs'

// and use directly
const peer = new Peer('pick-an-id', { key: 'myapikey' })

/* You can then attach this instance to Vue by... */
Vue.prototype.$peer = peer

By doing the above, you can now access it in all component files through this.$peer.

Going to close this as it isn't a direct issue with electron-vue. Feel free to comment back any questions.

All 2 comments

peerjs is not Vue plugin.
To load a library automatically, you could add ProvidePlugin in your webpack.config.js
See https://webpack.js.org/plugins/provide-plugin/

@Mistes974

Just as @re-fort stated, peerjs alone is not a Vue plugin and cannot be installed directly. To use peerjs in your JS files, simply import it and use it directly. For example...

main.js

// import
import Peer from 'peerjs'

// and use directly
const peer = new Peer('pick-an-id', { key: 'myapikey' })

/* You can then attach this instance to Vue by... */
Vue.prototype.$peer = peer

By doing the above, you can now access it in all component files through this.$peer.

Going to close this as it isn't a direct issue with electron-vue. Feel free to comment back any questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodrigomata picture rodrigomata  ·  3Comments

mvalim picture mvalim  ·  4Comments

webrtcn picture webrtcn  ·  3Comments

iwen-pengh picture iwen-pengh  ·  3Comments

haomehaode picture haomehaode  ·  3Comments