1.17.0 • Published 6 months ago

@azot-dev/cortex-storage-react-adapter v1.17.0

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

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[]>;
}
1.15.0

6 months ago

1.14.0

6 months ago

1.13.0

6 months ago

1.12.0

6 months ago

1.17.0

6 months ago

1.16.0

6 months ago

1.11.0

6 months ago

1.10.0

7 months ago

1.4.0

7 months ago

1.3.0

7 months ago

1.2.0

7 months ago

1.1.0

7 months ago

1.9.0

7 months ago

1.8.0

7 months ago

1.7.0

7 months ago

1.6.0

7 months ago

1.5.0

7 months ago