Skip to content

codewell/state-persistor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

94b74dd · Aug 9, 2021

History

13 Commits
Feb 20, 2020
Feb 20, 2020
Feb 20, 2020
Feb 20, 2020
Feb 20, 2020
Feb 20, 2020
Sep 13, 2019
Sep 13, 2019
Feb 20, 2020
Aug 9, 2021
Feb 20, 2020
Feb 20, 2020

Repository files navigation

@codewell/state-persistor

Minimalistic state persistor for front end applications with localstorage.

Installation

npm install @codewell/state-persistor

Basic usage

import { saveState, loadState, purgeState } from '@codewell/state-persistor';

const state = {}; // Some state
const STORAGE_KEY = 'myCoolUniqueApplicationStorageKey'; // Unique key to store the state in localstorage

// Persist the state
saveState(state, STORAGE_KEY);

// Get the persisted state
const loadedState = loadState(STORAGE_KEY);

// Clear any saved state
purgeState(STORAGE_KEY);

About

Write, read or purge localstorage based on key

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published