vue-local-storage-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Vue Local Storage Decorator

npm Build Status Coverage CodeFactor Known Vulnerabilities

This library fully depends on vue-class-component.

Description

It persists the component data by using local storage

License

MIT License

Install

npm i -S vue-local-storage-decorator

Usage

// In main.ts
import VueLocalStorageDecorator from 'vue-local-storage-decorator'
Vue.use(VueLocalStorageDecorator)

// In component
import { Persist } from 'vue-local-storage-decorator'
@Component({
  // It will use the component name to persist the data
  name: 'dummy'
})
export class DummyComponent extends Vue {
  // It will save in the local storage while the data is changed and will auto resume from local storage in created lifecycle
  @Persist()
  public dummyData: string[] = []

  public saveDummy() {
    // You can also call it manually
    this.persistData('dummyData')

    // You can get the data by calling getPersistData
    this.dummyData = this.getPersistData<string[]>('dummyData')
  }
}

Package Sidebar

Install

npm i vue-local-storage-decorator

Weekly Downloads

2

Version

0.2.1

License

MIT

Unpacked Size

17.5 kB

Total Files

7

Last publish

Collaborators

  • kc_vip30