unholy
A Nuxt.js module that injects a $state
helper for performing core
data mutations on the Vuex store.
Works with Nuxt.js 2.5 and above.
$state[.submodule].merge
:
merges object into state, overriding existing values
this$state
$state[.submodule].anull
:
set properties in the state to null
// Set single prop to nullthis$state // Set top-level props to nullthis$state // Set obj props to nullthis$state
$state[.submodule].push
:
push values into state arrays
this$state
$state[.submodule].splice
:
perform Array.splice()
on state arrays
this$state
$state[.submodule].empty
:
remove all items from arrays
this$state this$state
Installation
yarn add unholy
Setup
Add to the modules
section of your nuxt.config.js
:
modules: 'unholy'
Upgrade from 0.9
The latest version of unholy
is a major release: 1.0.0.
The 0.9 release (which overrides Vuex.Store.commit()
) for merging objects
remains available on npm.
Upgrading to 1.0 is strongly recommended.
Why "unholy"?
Because somewhere in the source code, you'll find this:
const vueAppPath = requireconst vueAppDistSuffixLen = lengthconst vueAppStoreBase = vueAppPathconst createStoreRegex = /\/\/ createStore[\0-\uFFFF]+?\}\n/
Which is used for tampering with @nuxt/vue-app
original store 😈