solid-awesome-hooks
Version:
A collection of awesome hooks for solid-js
31 lines (30 loc) • 963 B
TypeScript
import { type Accessor } from "solid-js";
type Serializable = number | string | boolean | object | null | undefined;
type SaveToStorageOptions = {
/** @default localStorage */
storage?: Storage;
/**
* If set to true it will save the data when the browser is idle
* @default true
*/
saveWhenIdle?: boolean;
/**
* If set to true it will save the data only after first change
* (it passed to solid's `on` `defer` option)
* @default true
*/
defer?: boolean;
/**
* If set to true it will remove the key from storage if the data is null or undefined
* @default false
*/
clearOnEmpty?: boolean;
};
/**
*
* @param key - key name in storage
* @param data - Reactive accessor to the data
* @param options
*/
export declare const useSaveToStorage: <T extends Serializable>(key: string, data: Accessor<T>, options?: SaveToStorageOptions) => void;
export {};