UNPKG

react-native-global-state-hooks

Version:

This is a package to easily handling global-state across your react-native-components No-redux... The library now includes @react-native-async-storage/async-storage to persist your state across sessions... if you want to keep using the old version without

27 lines (26 loc) 857 B
/** * Async Storage Manager */ export type AsyncStorageManager = { /** * Get item from storage * @param key storage key * @returns stored value or null if not found */ getItem: <T extends string | null>(key: string) => Promise<T>; /** * Set item in storage * @param key storage key * @param value value to store */ setItem: (key: string, value: string) => Promise<void>; }; /** * Wrapper to manage async storage manager * It tries to use @react-native-async-storage/async-storage by default * If not available, you can add your own async storage manager using the addAsyncStorageManager method */ export declare const asyncStorageWrapper: AsyncStorageManager & { addAsyncStorageManager: (callback: () => Promise<AsyncStorageManager>) => Promise<void>; }; export default asyncStorageWrapper;