Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex-class-decorator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex-class-decorator

Binding helpers for Vuex and vue-class-component

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vuex-class-decorator

Via vuex-class Binding helpers for Vuex and vue-class-component

Dependencies

Installation

$ npm i -S vuex-class-decorator

Example

import Vue from 'vue'
import {
  State,
  Getter,
  Action,
  Mutation,
  GetterSetter,
  Component,
  namespace
} from 'vuex-class'

const someModule = namespace('path/to/module')

@Component
export class MyComp extends Vue {
  @State('foo') stateFoo
  @State(state => state.bar) stateBar
  @Getter('foo') getterFoo
  @Action('foo') actionFoo
  @Mutation('foo') mutationFoo
  @someModule.Getter('foo') moduleGetterFoo
  @GetterSetter('getterKey','setterKey') gsFoo     //getterKey ---> getters , setterKey --> actions

  // If the argument is omitted, use the property name
  // for each state/getter/action/mutation type
  @State foo
  @Getter bar
  @Action baz
  @Mutation qux
  @GetterSetter gsBar
  @someModule.GetterSetter name

  created () {
    this.stateFoo // -> store.state.foo
    this.stateBar // -> store.state.bar
    this.getterFoo // -> store.getters.foo
    this.actionFoo({ value: true }) // -> store.dispatch('foo', { value: true })
    this.mutationFoo({ value: true }) // -> store.commit('foo', { value: true })
    this.moduleGetterFoo // -> store.getters['path/to/module/foo']
    this.gsBar  // -> store.getters.gsBar
    this.gsBar = 1      // -> store.dispatch('gsBar', 1)
    this.gsFoo = 'test' // -> store.dispatch('setterKey', 'test')
    this.name         // -> store.getters['path/to/module/name']
    this.name = 'myname' // -> store.dispatch('path/to/module/name', 'myname')
  }
}

License

MIT

Keywords

FAQs

Package last updated on 01 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc