taro-hooks
Version:
为 Taro 而设计的 Hooks Library
14 lines (13 loc) • 738 B
TypeScript
import Taro from '@tarojs/taro';
import type { RecordData, PromiseParamsAction, PromiseOptionalAction, UnionResult, UnionCallBackResult } from '../type';
export type Set<T = unknown> = PromiseParamsAction<(key: string, data: T) => void>;
export type Remove = PromiseOptionalAction<string>;
export type StorageInfo = Taro.getStorageInfo.SuccessCallbackOption & {
storage: RecordData;
};
declare function useStorage(): readonly [StorageInfo, {
readonly set: <T = string>(key: string, data?: T | undefined) => Promise<UnionResult<TaroGeneral.CallbackResult>>;
readonly get: <T_1 = RecordData<string, any>>(key?: string | string[]) => Promise<UnionCallBackResult<T_1>>;
readonly remove: Remove;
}];
export default useStorage;