Skip to content

Releases: galvez/vue-stator

v1.2.0

22 Nov 17:42
Compare
Choose a tag to compare

v1.2.0 (contains breaking changes! 💔)

As the beta release seemed stable we are releasing v1.2.0. Although its normally ill-advised, this release ships some breaking changes. The main reason why we not didnt release a new major release is that we released v1 only last week and with ~200 weekly downloads it seemed a bit optimistic to release v2 already.
Also the breaking changes are actually mostly bug fixes, as the docs already stated that getters/actions had the same fingerprint as Vuex getters/actions but that wasnt true. We are fixing that in this release but strictly speaking that is a breaking change.

Features

  • expose $set / $delete on store instance (68c4334)

These functions are convenience shortcuts to Vue.set and Vue.delete so you dont have to import Vue everywhere.

  myAction({ state }) {
    this.$set(state, 'propThatDidntExistYet', true)
  }
  • add mixin to map state by component option (f6d9809)

No more mapState, mapGetters or mapActions! See the readme for more info

  • allow statorMap to be a function (5e32620)

Bug Fixes

  • nuxt: allow to enable statorMap mixin as module option (6f1d6c1)
  • create module context outside for loop for actions (91dc6e9)
  • use similar fingerprints as Vuex for getters/actions (3d6fd1e)

v1.1.1

16 Nov 18:44
Compare
Choose a tag to compare

Release v1.1

The focus of this release was to improve the Nuxt.js module usability.

Also it add supports to alias module state by passing an object where the keys are the aliases:

  computed: {
    ...mapState({ alias: 'my/module/test' })
  }

Features

  • use nuxt vuex module for stator initialization (b72b62e)
  • nuxt: add disableVuex option (a307f8d)
  • support map aliases (d066f6e)

Bug Fixes

  • pass Nuxt ssrContext into store (00bb63d)
  • nuxt: in module its options (569b848)
  • nuxt: use stator dir (2516fd6)

v1.0.0

15 Nov 10:46
Compare
Choose a tag to compare

Release v1.0.0 🎉

We are releasing vue-stator v1 as we are introducing some breaking changes:

  • full module support with namespacing
    this breaks the old syntax that required you to pass two arguments. Similar to Vuex, vue-stator now uses slashed namespace paths to e.g. map state, getters and actions.
  • abstracted storage
    You can easily add any storage which has a similar interface as Storage (only the getItem and setItem methods are really required)

See the updated readme for more information

Registering module example

const myModule = {
  state() {
    return {
      myVar: 2
    }
  }
}

const config = {
  state() {
    return {
      rootVar: 1
    }
  },
  modules: {
    'my/module': myModule
  }
}

const stator = createStore(config)

stator.$state.rootVar // => 1
stator.$state.my.module.myVar // => 2

Or you can also register the module dynamically:

const stator = createStore(config)

stator.registerModule(myModule, 'my/module')

Namespacing syntax example

Old syntax:

// store/state.js
export default () => ({
  rootVar: 1,
  my: {
    myVar: 2
  }
})

// store/my.js
export const getters = {
  myGetter(state) {
    return state.myVar
  }
}

// within component.vue
  computed: {
    ...mapGetters(['my', 'myGetter'])
  }

New syntax:

// store/state.js
export default () => ({
  rootVar: 1
})

// store/my.js
export const state = () => ({
  myVar: 2
})

export const getters = {
  myGetter(state) {
    return state.myVar
  }
}

// within component.vue
  computed: {
    ...mapGetters(['my/myGetter'])
  }