Gathering detailed insights and metrics for vuex-dot
Gathering detailed insights and metrics for vuex-dot
Gathering detailed insights and metrics for vuex-dot
Gathering detailed insights and metrics for vuex-dot
tools for state mapping to computed with smooth and flexible v-model support
npm install vuex-dot
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
39 Stars
42 Commits
3 Forks
1 Watchers
1 Branches
2 Contributors
Updated on Aug 28, 2020
Latest Version
2.5.8
Package Id
vuex-dot@2.5.8
Unpacked Size
51.84 kB
Size
10.88 kB
File Count
12
NPM Version
6.1.0
Node Version
8.11.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Vue computed properties getters and/or setters generator with the ability to intercept each property change and dispatch vuex action or commit mutation or just hook your own callback. Also you can use plugins.
The main idea of this tool is to have mapState()
-like helper with an ability to set additional configuration using chainable methods.
There are some other packages on github - vuex-map-fields and vuex-bound for example, but after reading their docs and sources I've decided to create own package from scratch with such benefits
vuex
or vm
needed. This tool just generates getters and setters, which are done with performance in mind.1npm i vuex-dot
https://codepen.io/anon/pen/ERmBqK
1<template> 2 <button @click.stop="step++">next</button> 3</template> 4 5<script> 6 import { takeState } from 'vuex-dot'; 7 8 export default { 9 computed: { 10 step: takeState('wizard.step') 11 .commit('setWizardStep') 12 .map() 13 } 14 } 15</script>
store/index.js
1export default new Vuex.Store({ 2 state: { 3 wizard: { 4 step: 1 5 } 6 }, 7 mutations: { 8 setWizardStep(state, step) { 9 state.wizard.step = step; 10 } 11 } 12});
https://codepen.io/anon/pen/eKWqOm
1<template> 2 <form> 3 <input v-model="name"/> 4 <input v-model="email"/> 5 </form> 6</template> 7 8<script> 9 import { takeState } from 'vuex-dot'; 10 11 export default { 12 computed: { 13 ...takeState('user') 14 .expose(['name', 'email']) 15 .dispatch('editUser') 16 .map() 17 } 18 } 19</script>
1<template> 2 <form> 3 <input v-model="name"/> 4 <input v-model="email"/> 5 </form> 6</template> 7 8<script> 9 import { takeState } from 'vuex-dot'; 10 import validate from 'validate'; 11 const constraints = {name: {presence: true}}; 12 13 export default { 14 computed: { 15 ...takeState('user') 16 .expose([ 17 'name', 18 'email' 19 ]) 20 .hook(({ dispatch }, value, key) => { 21 if(validate.single(value, constraints[key])) { 22 dispatch('userEditAction', { key, value }); 23 } 24 }) 25 .map() 26 } 27 } 28</script>
Target mapper
Exposes some properties of target object into computed properties compatible bunch of getters or/and setters
Target
returns Target instance with specified path
Target
returns Target instance with specified state path
Target mapper
function
Param | Type | Description |
---|---|---|
path | string | dot-notation path to some property of your vm instance |
TargetExposition
Should be used if you need to map some properties of the object, selected as a target into your computed properties. It allows to attach action dispatcher or hook callback on each property change.
Also, both dispatch()
and hook()
can provide object mapped by Target instance to the callee, while setting
the second argument true
(you can read more in the documentation for them)
Param | Type | Description |
---|---|---|
projection | array | target object properties to be exposed |
Target
In fact, that's syntax sugar for hook()
method.
Sets mutation
to be commited on mapped property change
mutation
shall be called in the format:
commit(mutation, newValue)
Param | Type | Description |
---|---|---|
mutation | string | mutation name |
Target
In fact, that's syntax sugar for hook()
method.
Sets action
to be dispatched on mapped property change
Your action
shall be called in the format:
dispatch(action, newValue)
Param | Type | Description |
---|---|---|
action | string | action name |
Target
Set hook that should be run on mapped property change.
Param | Type |
---|---|
dispatcher | dispatcher |
*
returns computed property pair of getters or/and setters for specified projection.
If an alias is set, it can be used with spread operator setting provided alias as the computed property name
Param | Type | Description |
---|---|---|
alias | String | name of computed field target to be accessible |
Target
apply plugin
plugin is described by object, composed in such format:
1{ 2 setter: function(key, value, nextSetter) { //setter is mandatory 3 nextSetter(value); 4 }, 5 getter: function(key, nextGetter) { //getter is optional 6 return nextGetter(); 7 }, 8 inject: { // optional, here you can describe additional fields, you want to inject into result map 9 $internal: { 10 get() { ... }, 11 set(value) { ... } 12 } 13 } 14}
Param | Type | Description |
---|---|---|
plugin | Object | object, describing your plugin. |
function
Param | Type | Description |
---|---|---|
store | Store | vuex store |
value | mixed |
Exposes some properties of target object into computed properties compatible bunch of getters or/and setters
Param | Type |
---|---|
target | Target |
projection | Array |
TargetExposition
Sets mutation
to be commited on exposed field change
if sendTarget
is false
, action
shall be called in format:
commit(mutation, { key, value })
otherwise, if sendTarget
is set to true
commit(mutation, { target, key, value })
Hint: That's just syntax sugar for hook()
method.
Param | Type | Default | Description |
---|---|---|---|
mutation | String | name of mutation | |
sendTarget | Boolean | false | send target to action |
TargetExposition
Sets action
to be dispatched on exposed field change.
if sendTarget
is false
, action
shall be called in format:
dispatch(action, { key, value })
otherwise, if sendTarget
is set to true
dispatch(action, { target, key, value })
Hint: That's just syntax sugar for hook()
method.
Param | Type | Default | Description |
---|---|---|---|
action | String | name of action | |
sendTarget | Boolean | false | send target to action |
TargetExposition
set callback to be run on property change
Param | Type |
---|---|
dispatcher | dispatcher |
sendTarget | Boolean |
Object
generates map of getters or/and setters for specified projection
TargetExposition
look Target.use(plugin)
Param |
---|
plugin |
function
Param | Type | Description |
---|---|---|
store | Store | vuex store |
value | * | changed value |
key | String | key of changed field |
target | * | parent object of changed field |
Target
returns Target instance with specified path
Param | Type | Description |
---|---|---|
path | string | dotted path to target property of your component instance |
Target
returns Target instance with specified state path
Param |
---|
namespace |
path |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
50 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More