All Projects → zh-rocco → vue-auto-storage

zh-rocco / vue-auto-storage

Licence: MIT license
🍻 An automatic storage plugin for Vue2, persist the data with localStorage.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue-auto-storage

vue-link
One component to link them all 🔗
Stars: ✭ 65 (-22.62%)
Mutual labels:  vue-plugin
PlacenoteSDK-Unity
Placenote SDK and sample app for Unity
Stars: ✭ 78 (-7.14%)
Mutual labels:  persistence
core
Javascript Object Storage Helper
Stars: ✭ 70 (-16.67%)
Mutual labels:  persistent-storage
vite-plugin-webfont-dl
⚡ Webfont Download Vite Plugin - Make your Vite site load faster
Stars: ✭ 69 (-17.86%)
Mutual labels:  vue-plugin
vcrop
A simple Vue image cropping component.
Stars: ✭ 14 (-83.33%)
Mutual labels:  vue-plugin
linper
Linux Persistence Toolkit
Stars: ✭ 20 (-76.19%)
Mutual labels:  persistence
SilentETHMiner
A Silent (Hidden) Ethereum (ETH & ETC) Miner Builder
Stars: ✭ 219 (+160.71%)
Mutual labels:  persistence
vue-shell
Component VueJS to simulate a terminal.
Stars: ✭ 36 (-57.14%)
Mutual labels:  vue-plugin
vue-cli-plugin-chrome-ext
vue cli plugin that setup vue project for chrome extension
Stars: ✭ 86 (+2.38%)
Mutual labels:  vue-plugin
Persistence
Plugin para almacenar datos de forma persistente en Godot Engine 3
Stars: ✭ 20 (-76.19%)
Mutual labels:  persistence
vue-translator
A deadly simple i18n translate plugin for Vue, ready for Server Side Rendering.
Stars: ✭ 18 (-78.57%)
Mutual labels:  vue-plugin
js-coalaip
Javascript implementation for COALA IP
Stars: ✭ 18 (-78.57%)
Mutual labels:  persistence
android-room-example
Android Kotlin app showcasing the Room persistence library
Stars: ✭ 45 (-46.43%)
Mutual labels:  persistence
moosefs-csi
Container Storage Interface (CSI) for MooseFS
Stars: ✭ 44 (-47.62%)
Mutual labels:  persistent-storage
shoebox
ShoeBox is a Kotlin library for persistent data storage that supports views and the observer pattern. While often used with Kweb, it doesn't need to be.
Stars: ✭ 48 (-42.86%)
Mutual labels:  persistent-storage
sched
⏳ a high performance reliable task scheduling package in Go.
Stars: ✭ 46 (-45.24%)
Mutual labels:  persistence
X-Browser-Update-Vue
A Vue.js browser-update plugin
Stars: ✭ 25 (-70.24%)
Mutual labels:  vue-plugin
vue-methods-promise
Let Vue methods support return Promise
Stars: ✭ 35 (-58.33%)
Mutual labels:  vue-plugin
vuejs-emoji
vue2.x emoji plugin, autoload fontawesome
Stars: ✭ 32 (-61.9%)
Mutual labels:  vue-plugin
Rebus.SqlServer
🚌 Microsoft SQL Server transport and persistence for Rebus
Stars: ✭ 35 (-58.33%)
Mutual labels:  persistence

vue-auto-storage

An automatic storage plugin for Vue2, persist the data with localStorage.

vue-js downloads GitHub stars devDependencies npm-version Github tag Build Status GitHub license

Demo

Try it out

Requirements

Advantages

  • Simple API.
  • Small bundle size: 3.86KB (1.42KB gzipped).
  • No dependencies.

Attention

Obey the following:

  • Vue component must has a unique name field.
  • The target component can't used multiple times, eg: not used by v-for.

Installation

yarn add vue-auto-storage

Usage

Registration

main.js

import Vue from "vue";
import App from "./App.vue";
import AutoStorage from "vue-auto-storage";

Vue.use(AutoStorage);

// or with options

// Vue.use(AutoStorage, { debounce: 100 });

new Vue({
  render: (h) => h(App),
}).$mount("#app");

Example

Add autoStorage filed to Vue component's options object, declare the keypath of data you want to persist.

export default {
  name: "ComponentName",

  autoStorage: ["a.b", "c.0.d", "f"],

  data() {
    return {
      a: { b: "" },

      c: [{ d: "" }, { e: "" }],

      f: "",
    };
  },

  created() {},
};

Use in TypeScript:

import { Component, Vue } from "vue-property-decorator";

@Component({
  autoStorage: ["a.b", "c.0.d", "f"],
})
export default class MyComponent extends Vue {
  private a = { b: "" };
  private c = [{ d: "" }, { e: "" }];
  private f = "";
}

If you want persist an array's first item, use array.0 instead of array[0], why?

Methods

Function Description Parameters Type Example
clear(key) Clear storage. If no parameters, clear all AutoStorage cache. String, N/A this.$autoStorage.clear("a.b")

Plugin Configurations

Property Description Type Default
debounce Debounce time of watchers, unit: ms. Number 300
storage Any object following the Storage protocol. Object more localStorage

Stay tuned for more configurations.

Development

yarn dev

Build

yarn build:lib

Test

yarn test

Todo Features

  • Support Vuex.

License

MIT © zh-rocco

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].