ziko
Version:
A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...
48 lines (37 loc) • 1.2 kB
TypeScript
// use-storage.d.ts
export declare class UseStorage {
constructor(
storage: Storage,
globalKey: string,
initialValue?: Record<string, any>,
use_channel?: boolean
);
/** Current stored items */
readonly items: Record<string, any>;
/** Set entire storage */
set(data: Record<string, any>): this;
/** Merge new data into existing storage */
add(data: Record<string, any>): this;
/** Remove keys from storage */
remove(...keys: string[]): this;
/** Get a single key */
get(key: string): any;
/** Clear storage completely */
clear(): this;
/**
* Listen for any storage updates.
* Callback receives the data passed to the last .set() / .add() / .remove()
*/
onStorageUpdated(callback: (data: Record<string, any>) => void): this;
}
/** Factory functions */
export declare const useLocaleStorage: (
key: string,
initialValue?: Record<string, any>,
use_channel?: boolean
) => UseStorage;
export declare const useSessionStorage: (
key: string,
initialValue?: Record<string, any>,
use_channel?: boolean
) => UseStorage;