3.1.8 • Published 4 years ago

vuex-easy-access v3.1.8

Weekly downloads
623
License
MIT
Repository
github
Last release
4 years ago

What is Vuex Easy Access?

  1. Zero boilerplate Vuex → auto generated actions & mutations!
  2. Unified syntax for accessing your store through simple set() and get()

Full documentation

Motivation

Vuex is great for state management in a VueJS app, however it requires a lot of boilerplating setting up your store and all actions and mutations.

The Vuex philosophy

The philosophy of Vuex is to do everything through mutations that will record a history of the changes you make to the store. This makes it possible to easily track changes when things go wrong as your app grows.

The Vuex Easy Access philosophy

Instead of having to write all actions and mutations for each change you make to the store, wouldn't it be great if an action and mutation is generated for you from the start? That's exactly what Vuex Easy Access does!

Vuex Easy Access automatically generates actions and mutations for each state property!

JavaScriptVuex Easy Access
In vanilla JavaScript you can simply do:object.prop.nestedProp = newValwhy shouldn't you be able to do this with Vuex?With Vuex Easy Access you can!set('object.prop.nestedProp', newVal)

And the best part is, all state changes go through a mutation under the hood!

Features

  • Automatically generated actions & mutations to:
    • Set state values
    • Set nested state values
    • Delete values
    • Arrays: Push/shift/pop/splice values
    • Objects: use ID wildcards
  • Shorthand store.set() for all the above
  • Streamlined store.get() to get state valuess

Go to documentation

Short overview

1. auto-generated Vuex actions

_actions generated from state
State propseg. state: {someProp: {nestedProp: ''}}
Set valuesSet nested valuesDelete valuesdispatch('module/set/someProp', newVal)dispatch('module/set/someProp.nestedProp', newVal)dispatch('module/delete/someProp')dispatch('module/delete/someProp.nestedProp')
Array propseg. state: {someArray: []}
Push/shift/pop/splice valuesdispatch('module/set/someArray.push', newVal)dispatch('module/set/someArray.shift')dispatch('module/set/someArray.pop')dispatch('module/set/someArray.splice', [ind, del, newVal])
Objects with id wildcardeg. state: {someObject: {'*': ''}}
Set and deletedispatch('module/set/someObject.*', {[id]: newVal})dispatch('module/delete/someObject.*', id)

2. Easy Access shorthand

_available setters
State propseg. state: {someProp: {nestedProp: ''}}
Set valuesSet nested valuesDelete valuesset('module/someProp', newVal)*set('module/someProp.nestedProp', newVal)delete('module/someProp')delete('module/someProp.nestedProp')
Array propseg. state: {someArray: []}
Push/shift/pop/splice valuesset('module/someArray.push', newVal)set('module/someArray.shift')set('module/someArray.pop')set('module/someArray.splice', [ind, del, newVal])
Objects with id wildcardeg. state: {someObject: {'*': ''}}
Set and deleteset('module/someObject.*', {[id]: newVal})delete('module/someObject.*', id)

* set() and delete() are attached to the Vuex store object: store.set()

Installation and setup →

Support

If you like what I built, you can say thanks by buying me a coffee! :)

Thank you so much!! Every little bit helps.

3.1.8

4 years ago

3.1.7

5 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.5.2

6 years ago

2.5.1

6 years ago

2.5.0

6 years ago

2.4.8

6 years ago

2.4.7

6 years ago

2.4.6

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.4

6 years ago

2.3.3

6 years ago

2.3.2

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago