@azot-dev/cortex-storage-react-native-adapter

1.17.0 • Public • Published

React-native Storage Adapter

installation

npm i @azot-dev/cortex-storage-react-native-adapter

or

yarn add @azot-dev/cortex-storage-react-native-adapter

adapter

export * from '../storage.gateway';
import { StorageGateway } from '../storage.gateway';
import AsyncStorage from '@react-native-async-storage/async-storage';

export class ReactStorageAdapter implements StorageGateway {
  getItem = AsyncStorage.getItem;
  setItem = AsyncStorage.setItem;
  removeItem = AsyncStorage.removeItem;
  clear = AsyncStorage.clear;
  async getAllKeys() {
    const keys = await AsyncStorage.getAllKeys();
    return [...keys];
  }
}

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

Readme

Keywords

none

Package Sidebar

Install

npm i @azot-dev/cortex-storage-react-native-adapter

Weekly Downloads

19

Version

1.17.0

License

none

Unpacked Size

1.59 kB

Total Files

3

Last publish

Collaborators

  • bopzor_azot
  • john_berd