Gathering detailed insights and metrics for vuex-bound
Gathering detailed insights and metrics for vuex-bound
Gathering detailed insights and metrics for vuex-bound
Gathering detailed insights and metrics for vuex-bound
Vue two-way binding (v-model) for Vuex state and mutations.
npm install vuex-bound
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
44 Stars
46 Commits
4 Forks
2 Watchers
9 Branches
2 Contributors
Updated on Feb 28, 2025
Latest Version
1.3.2
Package Id
vuex-bound@1.3.2
Unpacked Size
26.40 kB
Size
5.67 kB
File Count
9
NPM Version
6.14.11
Node Version
14.16.0
Cumulative downloads
Total Downloads
1
28
Vue two-way binding (v-model) for Vuex state and mutations.
1$ npm i vuex-bound -S 2# or 3$ pnpm i vuex-bound -S 4# or 5$ yarn add vuex-bound
1// for commonjs 2const { mapModel, updateModel } = require('vuex-bound'); 3 4// for es modules 5import { mapModel, updateModel } from 'vuex-bound';
1/** 2 * Vuex 3 3 */ 4import Vue from 'vue'; 5import Vuex from 'vuex'; 6import createLogger from 'vuex/dist/logger'; 7import { updateModel } from 'vuex-bound'; 8 9Vue.use(Vuex); 10 11const store = new Vuex.Store({ 12 state: { 13 foo: '', 14 bar: { baz: '' }, 15 db: [ 16 { mongo: '3' }, 17 ], 18 }, 19 getters: {}, 20 mutations: { ...updateModel() }, 21 actions: {}, 22 plugins: [createLogger({ collapsed: false })], 23}); 24 25export default store; 26 27/** 28 * Vuex 4 29 */ 30import { createStore, createLogger } from 'vuex'; 31import { updateModel } from 'vuex-bound'; 32 33export const store = createStore({ 34 state: { 35 foo: '', 36 bar: { baz: '' }, 37 db: [ 38 { mongo: '3' }, 39 ], 40 }, 41 getters: {}, 42 mutations: { ...updateModel() }, 43 actions: {}, 44 plugins: [createLogger({ collapsed: false })], 45});
1<template> 2 <div> 3 <!-- basic --> 4 <input v-model="foo"> {{ foo }} 5 6 <!-- custom name --> 7 <input v-model="fooCustom"> {{ fooCustom }} 8 9 <!-- nested object --> 10 <input v-model="barBaz"> {{ barBaz }} 11 12 <!-- nested object with array --> 13 <input v-model="mongo"> {{ mongo }} 14 </div> 15</template> 16 17<script> 18import { mapModel } from 'vuex-bound'; 19 20export default { 21 computed: { 22 // your model 23 ...mapModel(['foo']), 24 // equal to 25 ...mapModel({ foo: state => state.foo }), 26 27 ...mapModel({ 28 // custom name 29 fooCustom: state => state.foo, 30 31 // nested object 32 barBaz: state => state.bar.baz, 33 34 // nested object with array 35 mongo: state => state.db[0].mongo, 36 }), 37 }, 38}; 39</script>
:warning: WARNING
Frankly, state
is static, you cannot use destructuring assignment and rename it because it will not be able to update the value.
1/** 2 * Vuex 3 3 */ 4import Vue from 'vue'; 5import Vuex from 'vuex'; 6import createLogger from 'vuex/dist/logger'; 7import { updateModel } from 'vuex-bound'; 8 9Vue.use(Vuex); 10 11const store = new Vuex.Store({ 12 modules: { 13 a: { 14 namespaced: true, 15 modules: { 16 b: { 17 namespaced: true, 18 state: { 19 foo: '', 20 bar: { baz: '' }, 21 db: [ 22 { mongo: '3' }, 23 ], 24 }, 25 actions: {}, 26 mutations: { ...updateModel() }, 27 getters: {}, 28 }, 29 }, 30 }, 31 }, 32 plugins: [createLogger({ collapsed: false })], 33}); 34 35export default store; 36 37/** 38 * Vuex 4 39 */ 40import { createStore, createLogger } from 'vuex'; 41import { updateModel } from 'vuex-bound'; 42 43export const store = createStore({ 44 modules: { 45 a: { 46 namespaced: true, 47 modules: { 48 b: { 49 namespaced: true, 50 state: { 51 foo: '', 52 bar: { baz: '' }, 53 db: [ 54 { mongo: '3' }, 55 ], 56 }, 57 actions: {}, 58 mutations: { ...updateModel() }, 59 getters: {}, 60 }, 61 }, 62 }, 63 }, 64 plugins: [createLogger({ collapsed: false })], 65});
1<template> 2 <div> 3 <!-- basic --> 4 <input v-model="foo"> {{ foo }} 5 6 <!-- custom name --> 7 <input v-model="fooCustom"> {{ fooCustom }} 8 9 <!-- nested object --> 10 <input v-model="barBaz"> {{ barBaz }} 11 12 <!-- nested object with array --> 13 <input v-model="mongo"> {{ mongo }} 14 </div> 15</template> 16 17<script> 18import { mapModel } from 'vuex-bound'; 19 20export default { 21 computed: { 22 // your model 23 ...mapModel('a/b', ['foo']), 24 // equal to 25 ...mapModel('a/b', { foo: state => state.foo }), 26 27 ...mapModel('a/b', { 28 // custom name 29 fooCustom: state => state.foo, 30 31 // nested object 32 barBaz: state => state.bar.baz, 33 34 // nested object with array 35 mongo: state => state.db[0].mongo, 36 }), 37 }, 38}; 39</script>
mapModel
Type: mapModel(namespace?: string, map: Array<string> | Object<function>): Object
updateModel
Type: updateModel(): Object
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/30 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
75 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
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 MoreLast 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