Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
An alternative approach to Vuex helpers for accessing state, getters and actions that doesn't rely on string constants.
An alternative, opinionated approach to Vuex helpers for accessing state, getters and actions that doesn't rely on string constants.
First install the npm package with
npm install --save vuex-alt
Then use the plugin, passing in the Vuex Store.
import Vuex from 'vuex';
import { VuexAltPlugin } from 'vuex-alt';
// use Vuex as usual
Vue.use(Vuex);
// create your store
const store = new Vuex.Store({ ... });
// use the VuexAltPlugin, and pass it
// the new Vuex Store
Vue.use(VuexAltPlugin, { store });
Vuex-Alt makes two intentional, opinionated assumptions about your Vuex code:
These two rules lead to more scalable state management code, and more predictable state changes.
Vuex-Alt provides an alternative approach to the Vuex helpers for mapState
, mapActions
, and mapGetters
.
The main difference between the Vuex-Alt helpers and the original Vuex helpers is that instead of accepting strings to specify the namespace and action/getter you want, access is done via functions and nested objects.
Provide an object that maps local Vuex instance properties to Vuex module properties.
For example, if you have a state property called count
on a Vuex store module called counter
you would access it like this:
computed: {
...mapState({
count: (state) => state.counter.count
})
}
Provide an object that maps local Vuex instance methods to Vuex module methods.
For example, if you have an action called increment()
on a Vuex store module called counter
you would access it like this:
methods: {
...mapActions({
increment: (actions) => actions.counter.increment
})
}
Now you can access it in your component via this.increment(10)
.
Provide an object that maps local Vuex instance properties to Vuex module getters.
For example, if you have a getter called countPlusTen()
on a Vuex store module called counter
you would access it like this:
computed: {
...mapGetters({
countPlusTen: (getters) => getters.counter.countPlusTen
})
}
FAQs
An alternative approach to Vuex helpers for accessing state, getters and actions that doesn't rely on string constants.
The npm package vuex-alt receives a total of 38 weekly downloads. As such, vuex-alt popularity was classified as not popular.
We found that vuex-alt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.