vuex-module-decorator

Programming vuex module as viewmodle
3,662
Install
npm install vuex-module-decorator
Latest Version:0.1.1
Vue:2
License:MIT
Last Updated:Jul 15, 2018
Links: GitHub  ·  npm
Maintainer: ihuke

vuex-module-decorator

Programming vuex module as viewmodle/redux.

Description

When programming vuex,we must manual invoke it by mapState、mapGetters、mapMutations、mapActions...,How tedious it's!Now vuex-module-decorator will automatic mapping store's module (state、getter、mutation、action) to vue,it's like programming viewmodel/redux。

Dependencies

Installation

$ npm install --save vuex-module-decorator
# or
$ yarn add vuex-module-decorator

Example

1.programming store's module

export default {
  namespaced: true,
  state: {
    amount: 10000
  },
  getters: {
    amounts: ({ amount }) => {
      ...
    }
  },
  mutations: {
    [COUNTER_UPDATER](https://github.com/ihuke/vuex-module-decorator/blob/HEAD/state, payload: number) {
      ...
    }
  },
  actions: {
    update(context) {
      ...
    }
  }
};

2.import module

  • if namespace is nudefined,module's name will be component's name,like example: Board->board
  • if namespace is "",it's meaning mapping store's root module。
import Module from "../../module";
import board from "@/store/board";

@Component
@Module(board, { namespace: "board" })
export default class Board extends Vue {
  // declare vuex action if need manual invoke
  update!: Function;

  invoke() {
    this.update();
  }
}

Related Packages

vuex-facing-decorator

Vue3 alternative solution for vuex-class.

254,012 15
spyfu-vuex-helpers

Utility functions for Vuex.

2,459 9
vuex-pathify

Ridiculously simple Vuex setup + wiring

322,817 1,358
direct-vuex

Use and implement your Vuex store with TypeScript types. Compatible with the Vue...

90,286 255

Version History

Version Released Vue License
0.1.1 ^2.5.16 MIT
0.1.0 ^2.5.16 MIT