1.0.1 • Published 5 years ago

unholy v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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.

this.$state.merge({
  propInState: {
    toBeUpdated: 2
  }
})
// Set single prop to null
this.$state.anull('prop')

// Set top-level props to null
this.$state.anull('prop', 'otherProp', ...)

// Set obj props to null
this.$state.anull({ obj: ['prop', 'otherProp', ...] })
this.$state.push({
  arrayInState: {
    toReceiveItems1: [2, 3] // push(2, 3)
    toReceiveItems2: ['a', 'b'] // push('a', 'b')
  }
})
this.$state.splice({
  arrayInState: {
    toHaveSplicedItems: [0, 2] // splice args
  }
})
this.$state.empty('arrayInState', 'anotherArrayInState', ...)

this.$state.empty({ obj: ['arrayInObj', 'anotherArrayInObj'] })

Installation

yarn add unholy

Setup

Add to the modules section of your nuxt.config.js:

export default {
  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 = require.resolve('@nuxt/vue-app')
const vueAppDistSuffixLen = p('/dist/vue-app.js').length
const vueAppStoreBase = vueAppPath.slice(0, vueAppPath.length - vueAppDistSuffixLen)
const createStoreRegex = /\/\/ createStore[\0-\uFFFF]+?\}\n/

Which is used for tampering with @nuxt/vue-app original store 😈

Credits

1.0.1

5 years ago

1.0.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago