Session Storage Client
This package offers a typed abstraction layer for interacting with the browser's sessionStorage
through a generically typed TypeScript class, SessionStorageClient.
🔧 Installation
npm i @acctglobal/session-storage-client
🖱️ Usage
import { SessionStorageClient } from '@acctglobal/session-storage-client';
interface ExampleInterface {
foo: string;
bar: number;
}
const exampleClient = new SessionStorageClient<ExampleInterface>('exampleKey');
The exampleClient
variable now has a couple of things going for you:
exampleClient.setProperty('prop1', 'this is an example');
exampleClient.setProperty('prop2', 2);
exampleClient.setProperty('prop3', 2);
exampleClient.setProperty('prop1', 42);
const prop1 = exampleClient.getProperty('prop1');
exampleClient.resetStorage();
✒️ Authors