https://github.com/kbdsbx/vuex-declaration
https://github.com/kbdsbx/vuex-declaration
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kbdsbx/vuex-declaration
- Owner: kbdsbx
- Created: 2019-01-15T03:39:30.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:08:17.000Z (almost 3 years ago)
- Last Synced: 2025-02-27T02:17:26.847Z (10 months ago)
- Language: JavaScript
- Size: 2.77 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-vue - vuex-declaration - Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world. (Utilities [🔝](#readme))
- awesome-vue - vuex-declaration - Declare state like props, make state inject to vuex dynamically when component created. (Components & Libraries / Utilities)
- awesome-vue - vuex-declaration - Declare state like props, make state inject to vuex dynamically when component created. (Utilities / State Management)
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' ] )
```