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.
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();