0.0.7 • Published 2 years ago

@sil/storage v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Storage

Save your state in localstorage and automatically retrieve on initialisation.

Installation

npm install @sil/storage

Usage

Example in Vue, initialize a state and make sure the state taken from local storage when available. The watchState makes sure your state will automatically be saved whenever changes are made.

import { reactive } from "vue";
import { retrieveState, watchState } from "@sil/storage";

const state = reactive(
  retrieveState(
    {
      count: 0,
    },
    "MY_STATE"
  )
);

watchState(state, "MY_STATE");

Options

You can add the options to your retrieveState and watchState in order to change defaults.

OptionDefaultDescription
verbosefalseShow logging in console whenever an action happens

example:

const options = {
  verbose: true,
};

const state = reactive(
  retrieveState(
    {
      count: 0,
    },
    "MY_STATE",
    options
  )
);

watchState(state, "MY_STATE", options);
0.0.3

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago