yarn vuex 2.1.0

latest releases: 4.1.0, 4.0.2, 4.0.1...
7 years ago

New

Module Namespacing

Thanks to the great work by @ktsn for bringing us this feature.

Modules can now be auto-namespaced by using the new namespaced: true option. The getters, actions and mutations inside a namespaced module will automatically be prefixed with a namespaced inferred from the module's registration path. For example:

  const store = new Vuex.Store({
    modules: {
      foo: {
        namespaced: true,
        // ...
      }
    }
  })

The foo module will automatically get assigned the namespace foo/.

Everything inside the module are auto resolved to respect the namespace, so toggling between namespaced or not does not affect the code inside the module itself.

See updated docs for more details.

Helpers for Namespaced Modules

You can now pass a namespace string as the first argument to the mapState, mapGetters, mapActions and mapMutations helpers, so that the mappings are resolved using that module as the context:

computed: {
  ...mapState('foo', {
    // state is the state of the `foo/` module instead of root
    bar: state => state.bar
  }
},
methods: {
  ...mapActions('foo', [
    // map this.doSomething() to this.$store.dispatch('foo/doSomething')
    'doSomething'
  ])
}

Updated docs.

Don't miss a new vuex release

NewReleases is sending notifications on new releases.