@springtree/eva-sdk-core-storage
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

@springtree/eva-sdk-core-storage

Provides a wrapper around browser localStorage. If localStorage is unvailable (private mode browsing) it will fallback to memory storage solution. This will allow your app and other packages form the SDK to use a consistent API. It will also allow for normal storage functionality within a private browsing session.

Usage

import { EvaStorage } from '@springtree/eva-sdk-core-storage';

// Declare your own storage keys
//
export interface IMyAppStorage {
  'key1'?: string;
  'key2'?: string;
}

// Instatiate with out storage shape for type completion on get/set methods
//
const evaStorage = new EvaStorage<IMyAppStorage>();

// Provides methods as found on browser localStorage
//
evaStorage.getItem( 'key2' );

evaStorage.setItem( 'key1', 'my value' );

evaStorage.removeItem( 'key2' );

evaStorage.clear();

Readme

Keywords

none

Package Sidebar

Install

npm i @springtree/eva-sdk-core-storage

Weekly Downloads

588

Version

2.0.1

License

UNLICENSED

Unpacked Size

11.7 kB

Total Files

7

Last publish

Collaborators

  • mdoeswijk
  • janvandenberg
  • adebree
  • appie
  • springtree_solutions