Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/kbdsbx/vuex-declaration


https://github.com/kbdsbx/vuex-declaration

Last synced: about 1 month ago
JSON representation

Lists

README

        

# Vuex Declaration

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

## Usage

```bash
npm i vuex-declaration
```

```js
import vuecDeclaration from 'vuex-declaration'
import Vue from 'vue'
Vue.use( vuexDeclaration );
```

```js
Vue.component( 'self-component', {
data () { ... },
props : [ ... ],
created () { ... },

// Declare states
state : [ 'state-a', 'state-b' ],
} )
```

```js
export default {
// Declare state with module.
state : {
'state-a' : {
module : 'module-a',
}
}
}
```

## Apis

#### setStoreModule
Append states to existing modules.

```js
import { setStoreModule } from 'vuex-declaration'

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

#### resetStoreModule
Unreginster all modules from $store and then reset these.

```js
import { resetStoreModule } from 'vuex-declaration'

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