This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@lollipop-onl/vuekey

0.1.1 • Public • Published

vuekey

vuekey is a library of typesafe data path for @Watch and vm.set.

Installation

$ npm i --save @lollipop-onl/vuekey
# or
$ yarn add @lollipop-onl/vuekey

Example

Simple Example

import { Component, Watch, Vue } from 'vue-property-decorator';
import { setupVuekey } from '@lollipop-onl/vuekey';

const vuekey = setupVuekey<SampleComponent>();

@Component
export default class SampleComponent extends Vue {
  counter = {
    count: 0,
    updatedAt: Date.now()
  };

  @Watch(vuekey('counter', 'count'))
  onUpdateCount(): void {
    this.$set(...vuekey(this.counter, 'updatedAt', Date.now()));
  }
}

with vuex-typesafe-helper

Typesafely watch store data with @lollipop-onl/vuex-typesafe-helper.

import { Component, Watch, Vue } from 'vue-property-decorator';
import { setupVuekey } from '@lollipop-onl/vuekey';
import { RootStore } from './types/vuex';

const vuekey = setupVuekey<SampleComponent>();

@Component
export default class SampleComponent extends Vue {
  $store!: RootStore;

  @Watch(vuekey('$store', 'state', 'profile', 'birthday'))
  onUpdateBirthday(): void {
    // do something
  }
}

Notice !

  • vuekey can verify up to 10 depths
  • watch AAAA support only simple path.
    • OK: foo.bar.baz
    • NG: foo[0], foo['bar-baz']

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @lollipop-onl/vuekey

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

4.15 kB

Total Files

3

Last publish

Collaborators

  • lollipop-onl