CupThread React Native & Expo SDK - v0.1.0
    Preparing search index...

    Interface TokenStorageAdapter

    Interface for pluggable key-value persistence adapters used by UserTokenStore.

    Compatible with AsyncStorage, expo-secure-store, MMKV, localStorage, or in-memory dictionaries.

    import AsyncStorage from '@react-native-async-storage/async-storage';
    import { TokenStorageAdapter, UserTokenStore } from '@cupthread/react-native';

    const adapter: TokenStorageAdapter = {
    getItem: (key) => AsyncStorage.getItem(key),
    setItem: (key, val) => AsyncStorage.setItem(key, val),
    removeItem: (key) => AsyncStorage.removeItem(key),
    };

    UserTokenStore.configure(adapter);
    interface TokenStorageAdapter {
        getItem(key: string): string | Promise<string | null> | null;
        removeItem?(key: string): void | Promise<void>;
        setItem(key: string, value: string): void | Promise<void>;
    }
    Index
    • Retrieves the stored string value for the given storage key.

      Parameters

      • key: string

        The unique storage identifier.

      Returns string | Promise<string | null> | null

      Stored string value, null if not found, or a Promise resolving to it.

    • Optional cleanup handler to remove an entry from storage.

      Parameters

      • key: string

        The unique storage identifier to delete.

      Returns void | Promise<void>

    • Persists a key-value pair into storage.

      Parameters

      • key: string

        The unique storage identifier.

      • value: string

        The string payload to persist.

      Returns void | Promise<void>