@ludens-reklame/preserve
TypeScript icon, indicating that this package has built-in type declarations

2.0.8 • Public • Published

Preserve

A state lib for keeping track of and change localStorage data

Build Status PRs Welcome

Install

 npm install @ludens-reklame/preserve

or with Yarn

yarn add @ludens-reklame/preserve

Basic usage

import preserve from '@ludens-reklame/preserve';

// Make an item you want to keep track of.
const myItem = preserve('myData');

// Get the current data from localStorage
myItem.get();

// Update the localStorage data.
myItem.set(2);

// Listen to changes that happens within your localStorage item
myItem.subscribe(nextData => {
  console.log(nextData); // 2
});

// Clear the item from localStorage
myItem.clearItem();

Readme

Keywords

none

Package Sidebar

Install

npm i @ludens-reklame/preserve

Weekly Downloads

0

Version

2.0.8

License

MIT

Unpacked Size

6.04 kB

Total Files

14

Last publish

Collaborators

  • emilswebbod
  • stianba
  • oyvindhermansen