This wrapper has been written with the goal of being storage-agnostic. This means that by default, it will make use of react-native's AsyncStorage
API, but feel free to write your own driver and use anything you want, like the amazing realm.
Your custom driver must implement these 3 methods that are promises.
- getItem(key: string): Promise;
- setItem(key: string, value: string, callback?: (err: any, value: string) => any): Promise;
- removeItem(key: string): Promise;
As of 2.2.0
, an SQLite driver is baked-in with the module. Install SQLite in your project by following these instructions and set it as your custom driver like this :
import APIpeline, { drivers } from 'apipeline';
import SQLite from 'react-native-sqlite-storage';
// ...
const api = new APIpeline(API_OPTIONS, API_SERVICES);
drivers.sqliteDriver(SQLite, { debug: false }).then((driver) => {
api.setCacheDriver(driver);
});