@azot-dev/cortex-storage-react-adapter
v1.17.0
Published
```sh npm i @azot-dev/cortex-storage-react-adapter ``` or ```sh yarn add @azot-dev/cortex-storage-react-adapter ```
Downloads
36
Readme
React Storage Adapter
installation
npm i @azot-dev/cortex-storage-react-adapter
or
yarn add @azot-dev/cortex-storage-react-adapter
adapter
export * from '../storage.gateway';
import { StorageGateway } from '../storage.gateway';
export class ReactStorageAdapter implements StorageGateway {
async getItem(key: string) {
return localStorage.getItem(key);
}
async setItem(key: string, value: any) {
return localStorage.setItem(key, value);
}
async removeItem(key: string) {
localStorage.removeItem(key);
}
async clear() {
localStorage.clear();
}
async getAllKeys() {
return Object.keys(localStorage);
}
}
gateway
export interface StorageGateway {
getItem(key: string): Promise<any>;
setItem(key: string, value: any): Promise<void>;
removeItem(key: string): Promise<void>;
clear(): Promise<void>;
getAllKeys(): Promise<string[]>;
}