-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible to disable auto-connect? #137
Comments
I'm looking to solve a similar problem. It's possible to load the socket connection at a component level–not just with This is how I have it working–the modified component from the example: [Edited to fix incorrect implementation]. I'm not a Vue expert, and I don't know if this is the proper way to load a plugin on a component level. <script>
import Vue from 'vue' // Import Vue for the component–it is not a Global in the Webpack build.
import io from 'socket.io-client'
import VueSocketIO from 'vue-socket.io'
Vue.use(VueSocketIO, SocketInstance)
// Setup the socket.io connection with the vue-socket.io library
const SocketInstance = io() // by default io-client tries to connect to the same host
data () {
return {
isConnected: false,
socketMessage: ''
}
},
// rest of the component methods from this projects readme Still looking for a way to defer a way to call the vue-socket.io plugin from the component until some action is completed by the user, e.g., a click method. Not quite sure how to do this since this plugin (vue-socket.io) requires an Currently, I'm working around this by calling the above component only when I need to establish the connection. This plugin (vue-socket.io) takes a standatd |
Try someting like this: import VueSocketio from 'vue-socket.io'; let sck = Socket('http://127.0.0.1:5121',{ reconnectionAttempts, reconnectionDelay, reconnectionDelayMax, timeout are vars i use for my project porpuse. |
Try in your main.js Vue.use(new VueSocketIO({
connection: YOUR_CONNECTION,
options: { autoConnect: false }
})); and in components call |
I tried @Vsevo1od's answer, but found import SocketIO from 'socket.io-client'
import VueSocketIO from 'vue-socket.io'
Vue.use(new VueSocketIO({
connection: SocketIO(location.origin, {
path: '/socket-io',
autoConnect: false,
})
}))
|
I've searched around for a solution but can't find anything. I am also new to Vue so if there's a way to do it with Vue itself any direction would be helpful.
Additionally, if we could pass options to do this via the install method that would be great.
The text was updated successfully, but these errors were encountered: