Skip to content

kbdsbx/vuex-declaration

Repository files navigation

Vuex Declaration

Declare state like props, make state inject to vuex dynamically when component created.

Usage

npm i vuex-declaration
import vuecDeclaration from 'vuex-declaration'
import Vue from 'vue'
Vue.use( vuexDeclaration );
Vue.component( 'self-component', {
    data () { ... },
    props : [ ... ],
    created () { ... },

    // Declare states
    state : [ 'state-a', 'state-b' ],
} )
export default {
    // Declare state with module.
    state : {
        'state-a' : {
            module : 'module-a',
        }
    }
}

Apis

setStoreModule

Append states to existing modules.

import { setStoreModule } from 'vuex-declaration'

setStoreModule( this.$store, [ 'state-a', 'state-b' ] )

resetStoreModule

Unreginster all modules from $store and then reset these.

import { resetStoreModule } from 'vuex-declaration'

resetStoreModule( this.$store, [ 'state-a', 'state-b' ] )

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published