{"_id":"@bye_past/vuex-helpers","_rev":"1-a590318133b55c81554a7a9aafa37ec3","name":"@bye_past/vuex-helpers","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@bye_past/vuex-helpers","version":"0.1.0","description":"vuex-helpers is a utility library for Vue 3 and Vuex 4, simplifying the use of Vuex's mapper functions. This library provides a set of hooks for Vuex, making it more concise to use Vuex in Vue components.","type":"module","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rollup -c","commit":"npx cz"},"repository":{"type":"git","url":"git+https://github.com/ByePastHub/vuex-helpers.git"},"keywords":["vuex-helpers","vue","vue-router"],"config":{"commitizen":{"path":"node_modules/cz-git","czConfig":"cz.config.mjs"}},"author":{"name":"ByePast"},"license":"MIT","devDependencies":{"@rollup/plugin-typescript":"^11.1.2","@vue/compiler-sfc":"^3.3.4","commitizen":"^4.3.0","cz-git":"^1.7.1","husky":"7","rollup":"^3.28.0","tslib":"^2.6.1","typescript":"^5.1.6","vue":"^3.3.4","vuex":"^4.1.0"},"gitHead":"406d0db6a8efb7fc448cc2a2d50c0885f40df74f","bugs":{"url":"https://github.com/ByePastHub/vuex-helpers/issues"},"homepage":"https://github.com/ByePastHub/vuex-helpers#readme","_id":"@bye_past/vuex-helpers@0.1.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-GRXMo34g+rMZy6B7t0s5GX8vPFB72Peo+bl1Dq8T4mVr8ae3holddCD14vzv7rg18/4k0UvTtQbo1jMPSdqDUQ==","shasum":"b82d1570ee8d36ce28d0d8c373203bc31b7a144b","tarball":"https://registry.npmjs.org/@bye_past/vuex-helpers/-/vuex-helpers-0.1.0.tgz","fileCount":6,"unpackedSize":8801,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFId3FxKM4pqOoh/R2LypZE4cKtr4kmNKT1C6PGLX2YYAiB9hQ6wlNipWiDZjZVG+H5tzIvePAob20EMPlS0yl2cDQ=="}]},"_npmUser":{"name":"bye_past","email":"347904341@qq.com"},"directories":{},"maintainers":[{"name":"bye_past","email":"347904341@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-helpers_0.1.0_1692117512938_0.0297343740640299"},"_hasShrinkwrap":false},"0.1.1":{"name":"@bye_past/vuex-helpers","version":"0.1.1","description":"vuex-helpers is a utility library for Vue 3 and Vuex 4, simplifying the use of Vuex's mapper functions. This library provides a set of hooks for Vuex, making it more concise to use Vuex in Vue components.","type":"module","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rollup -c","commit":"npx cz"},"repository":{"type":"git","url":"git+https://github.com/ByePastHub/vuex-helpers.git"},"keywords":["vuex-helpers","vue","vue-router"],"config":{"commitizen":{"path":"node_modules/cz-git","czConfig":"cz.config.mjs"}},"author":{"name":"ByePast"},"license":"MIT","devDependencies":{"@rollup/plugin-typescript":"^11.1.2","@vue/compiler-sfc":"^3.3.4","commitizen":"^4.3.0","cz-git":"^1.7.1","husky":"7","rollup":"^3.28.0","tslib":"^2.6.1","typescript":"^5.1.6","vue":"^3.3.4","vuex":"^4.1.0"},"gitHead":"daa9d9bb1f7f5dcd57cf6108bcefc1edb25eb7b9","bugs":{"url":"https://github.com/ByePastHub/vuex-helpers/issues"},"homepage":"https://github.com/ByePastHub/vuex-helpers#readme","_id":"@bye_past/vuex-helpers@0.1.1","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-Zd7oj4JmIhvmIUpCtlmeT+a4H0xCpaR3WEklUBcExhtvKj+bL9Ypf01SND0uTc7hmm7W7Bv+tDOL51FZjakN0w==","shasum":"361e5c541cc7bce4efb3a5ef79fd7a8cda3ddd59","tarball":"https://registry.npmjs.org/@bye_past/vuex-helpers/-/vuex-helpers-0.1.1.tgz","fileCount":6,"unpackedSize":10660,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICxer6rc6sDNUwEvvjQIbTl95WefBNYbSo1ZSWeK8oNwAiEAt8jdyXmSrpmHF26oSWh+/K1Yo4tT+SEoaV7zSxP7ejo="}]},"_npmUser":{"name":"bye_past","email":"347904341@qq.com"},"directories":{},"maintainers":[{"name":"bye_past","email":"347904341@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-helpers_0.1.1_1692163446609_0.19334050615945841"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-15T16:38:32.868Z","0.1.0":"2023-08-15T16:38:33.167Z","modified":"2023-08-16T05:24:06.977Z","0.1.1":"2023-08-16T05:24:06.821Z"},"maintainers":[{"name":"bye_past","email":"347904341@qq.com"}],"description":"vuex-helpers is a utility library for Vue 3 and Vuex 4, simplifying the use of Vuex's mapper functions. This library provides a set of hooks for Vuex, making it more concise to use Vuex in Vue components.","homepage":"https://github.com/ByePastHub/vuex-helpers#readme","keywords":["vuex-helpers","vue","vue-router"],"repository":{"type":"git","url":"git+https://github.com/ByePastHub/vuex-helpers.git"},"author":{"name":"ByePast"},"bugs":{"url":"https://github.com/ByePastHub/vuex-helpers/issues"},"license":"MIT","readme":"# Vuex Helpers\n\n`vuex-helpers` is a utility library for Vue 3 and Vuex 4, simplifying the use of Vuex's mapper functions. This library provides a set of hooks for Vuex, making it more concise to use Vuex in Vue components.\n\n## Language\n\n<a href=\"./README-zh_CN.md\">中文</a></br>\n<a href=\"./README.md\">English</a>\n\n## Installation\n\nWith npm: `npm install @bye_past/vuex-helpers --save`\n\n## Usage\n### Get started\n\n#### use\n```javascript\nimport { useState, useGetters, useMutations, useActions } from '@bye_past/vuex-helpers';\n\nconst { platform } = useState(['platform']); // no namespace module\nconst { userInfo, loading } = useState('user', ['userInfo', 'loading']); // user namespace module\nconst { getUserId } = useGetters('user', ['getUserId']);\nconst { setUserInfo } = useMutations('user', ['setUserInfo']);\nconst { getUserInfo } = useActions('user', ['getUserInfo']);\n\n// The return values ​​of useState and useGetters are all responsive data\n```\n#### Store\n```typescript\n// store/index.ts\nimport { createStore } from 'vuex';\n\nconst store = createStore({\n  strict: true,\n  state: {\n    platform: 'PC'\n  },\n  modules: {\n    user: {\n      namespaced: true,\n      state: {\n        userInfo: {\n          name: '',\n          userId: '',\n        },\n        loading: false\n      } as State,\n\n      getters: {\n        getUserId: (state: State) => state.userInfo.userId,\n        isLogin: (state: State) => !!state.userInfo.userId,\n      },\n\n      mutations: {\n        setUserInfo: (state: State, userInfo: UserInfo) => (state.userInfo = userInfo),\n        setLoading: (state: State, loading: boolean) => (state.loading = loading),\n      },\n\n      actions: {\n        getUserInfo: ({ commit }: { commit: (mutation: string, data: any) => void }) => new Promise(resolve => {\n          commit('setLoading', true)\n          setTimeout(() => {\n            const data = {\n              name: '张三',\n              userId: '1',\n            };\n            resolve(data);\n            commit('setUserInfo', data);\n            commit('setLoading', false)\n          }, 2000)\n        })\n      },\n    }\n  },\n});\n\ninterface UserInfo {\n  name: string;\n  userId: string;\n}\n\ninterface State {\n  userInfo: UserInfo;\n  loading: boolean\n}\n\nexport default store;\n```\n\n### 1. `useState`\n\nFor mapping Vuex actions to your Vue component:\n\n```javascript\nimport { useState } from 'vuex-helpers';\n\nconst actions = useState(['myAction']);\n```\n\n### 2. `useGetters`\n\nFor mapping Vuex getters to your Vue component:\n\n```javascript\nimport { useGetters } from 'vuex-helpers';\n\nconst getters = useGetters(['myGetter']);\n```\n\n### 4. `useMutations`\n\nFor mapping Vuex mutations to your Vue component:\n\n```javascript\nimport { useMutations } from 'vuex-helpers';\n\nconst mutations = useMutations(['myMutation']);\n```\n\n### 4. `useActions`\n\nFor mapping Vuex actions to your Vue component:\n\n```javascript\nimport { useActions } from 'vuex-helpers';\n\nconst actions = useActions(['myAction']);\n```\n\n### Contributions\nPRs and Issues are welcome!\n","readmeFilename":"README.md"}