Hiyve Components - v1.0.0
    Preparing search index...

    Interface StorageAdapter

    Interface for storage adapters used to persist device preferences.

    Implement this interface to provide a custom storage backend. Methods may return values synchronously or as promises -- the store handles both. For most React Native apps, use createAsyncStorageAdapter which wraps @react-native-async-storage/async-storage with a sync cache.

    Custom in-memory storage (useful for testing):

    const memoryStorage: StorageAdapter = {
    _data: new Map<string, string>(),
    getItem(key: string) { return this._data.get(key) ?? null; },
    setItem(key: string, value: string) { this._data.set(key, value); },
    };

    createAsyncStorageAdapter for the recommended AsyncStorage wrapper

    interface StorageAdapter {
        getItem(key: string): string | Promise<string | null> | null;
        setItem(key: string, value: string): void | Promise<void>;
    }
    Index

    Methods

    • Retrieve a value by key.

      Parameters

      • key: string

        The storage key

      Returns string | Promise<string | null> | null

      The stored value, null if not found, or a Promise resolving to either

    • Store a value by key.

      Parameters

      • key: string

        The storage key

      • value: string

        The value to store

      Returns void | Promise<void>