Skip to content
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

Add a uninstall or reset method #416

Open
JonLev opened this issue Aug 26, 2019 · 4 comments
Open

Add a uninstall or reset method #416

JonLev opened this issue Aug 26, 2019 · 4 comments
Labels
question 🤔 Further information is requested

Comments

@JonLev
Copy link

JonLev commented Aug 26, 2019

Hi,

I use this great lib for a chat widget, with the constraint to have the possibility of a dynamic reset. The issue is that when I make the reset I need to re-set the socket instance used by VueSocketIOExt with new parameters.
What I do today is:

// First set-up
Vue.use(
        VueSocketIOExt,
        io(SOCKET_URL, OPTIONS),
)
// Before the reset
Vue.prototype.$socket.client.close();
Vue.prototype.$socket.client.destroy();
// Then the reset happening:
Vue.use(
        VueSocketIOExt,
        io(SOCKET_URL, MY_NEW_OPTIONS),
)

It seems that do not work because of VueJS use logic that do not apply all operations if the module was already installed:
https://github.com/vuejs/vue/blob/399b53661b167e678e1c740ce788ff6699096734/test/unit/features/global-api/use.spec.js#L20

The result is that the emission try to use the old instance of SocketIO client and not the new one I just set. Would you consider in your roadmap to split the installation and the set of the SocketIO client ? today I need to do some hack like:

    const installedPluginIndex = Vue._installedPlugins.indexOf(VueSocketio);
    if (installedPluginIndex > 0) {
        Vue._installedPlugins.splice(installedPluginIndex, 1);
    }

but depending of VueJS core keys and that's not good...

@probil probil added the question 🤔 Further information is requested label Aug 27, 2019
@capndave
Copy link
Contributor

capndave commented Sep 7, 2019

@probil: This is a bit over my head, but a comment to this post suggests that this Vuex method may demonstrate a way to un-use / uninstall a Vue plugin. Will try to research more later.

@ingles98
Copy link

ingles98 commented Jun 2, 2020

I need this. My current project requires me to implement server selection for the users. When connecting to the first server, users cannot just "logout" and connect to a different one. Any way around this ?

@disolva
Copy link

disolva commented Mar 24, 2021

Any news on this?
Many thanks

@cybersupernova
Copy link

We also have a similar condition designing a SPA where we want to change socket connection on route change, depending upon route params.

I tried destroying the this.$socket.client object but this plugin seems not to emit events on the new connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🤔 Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants