0.0.7 • Published 8 months ago

@sil/storage v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months 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

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.7

8 months ago

0.0.6

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago