#StackBounty: #vue.js #vuejs2 #vuex #vue-router #vuex-modules Vuex unregisterModule what does it do?

Bounty: 50

I’m a bit confused with what unregisterModule is actually doing.

If we have a module like so:

{
    state: {
        page: 1
    }
}

Then un/register it dynamically:

beforeCreate() {        
    this.$store.registerModule('items', store);
},

beforeDestroy() {
    this.$store.unregisterModule('items');
},

If we make a change to page navigate a way (which triggers unregister) then navigate back.

It seems the state persists? I would think unregister completely kills the module and all data, states, etc?

I can make the state a function like so:

{
    state() {
        return {
            page: 1
        }
    }
}

But, then it still doesn’t change the question then of what does unregisterModule actually do then?

Also does it mean I would either have to change all my state objects into functions or have some kind of reset method on unregister. This seems quite pointless, what am I missing here?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.