Skip to content

Kelin2025/vue-data-stash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-data-stash

Save component data for rainy day

What?

This small mixin allows you to define stashable data in your components i.e. data that will be saved until next time when component will be used.

Why?

I'm bored to write localStorage.setItem for every time I need to save some data.

When to use?

See this

Install

Install via NPM:

npm install vue-data-stash

Add it globally:

import VueDataStash from 'vue-data-stash'

Vue.use(VueDataStash)

Or in a single component:

import { mixin } from 'vue-data-stash'

export default {
  mixins: [mixin]
}

Usage

Just add stash property like it's just data:

export default {
  name: 'MyComponent',
  stash: () => ({
    activeId: true
  })
}

NOTE: Name for localStorage is based on the name option

About

Save component data for rainy day

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published