Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

vuex-connect-namespace-helper

1.1.0 • Public • Published

vuex-connect-namespace-helper

npm version Build Status

A binding namespaced module helper for vuex-connect.

Example

const store = new Vuex.Store({
  state: {
    foo: 'foo',
  },
  modules: {
    moduleName: {
      namespaced: true,
      state: {
        bar: 'bar',
      },
      mutations: {
        barMutation(state, payload) {
          state.bar = payload
        },
      },
      actions: {
        barAction({ commit }, payload) {
          commit('barMutation', payload)
        },
      },
      getters: {
        barbar: state => state.bar + state.bar,
      },
    },
  },
})
import { connect } from 'vuex-connect'
import {
  stateToProps,
  gettersToProps,
  mutationsToEvents,
  mutationsToProps,
  actionsToEvents,
  actionsToProps,
} from 'vuex-connect-namespace-helper'
import MyComponent from './MyComponent'
 
export default connect({
  stateToProps: {
    foo: 'foo',
    ...stateToProps('moduleName', {
      bar: 'bar',
    }),
  },
  gettersToProps: gettersToProps('moduleName', {
    barbar: 'barbar',
  }),
  mutationsToProps: mutationsToProps('moduleName', {
    testMutation: 'barMutation',
  }),
  mutationsToEvents: mutationsToEvents('moduleName', {
    testMutationEvent: 'barMutation',
  }),
  actionsToProps: actionsToProps('moduleName', {
    testAction: 'barAction',
  }),
  actionsToEvents: actionsToEvents('moduleName', {
    testActionEvent: 'barAction',
  }),
})(MyComponent)

API

helperFunction(namespace, options) -> Object

  • stateToProps
  • gettersToProps
  • mutationsToEvents
  • mutationsToProps
  • actionsToEvents
  • actionsToProps

install

npm i vuex-connect-namespace-helper

Downloadsweekly downloads

147

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar