@redocly/theme
Version:
Shared UI components lib
18 lines (17 loc) • 618 B
TypeScript
type Store<T> = {
getValue: (defaultValue: T) => T;
setValue: (next: T) => void;
subscribe: (callback: () => void) => Unsubscribe;
};
type Unsubscribe = () => void;
type CreateStoreProps<T> = {
storageKey: string;
storageType?: 'localStorage' | 'sessionStorage';
serializer?: {
parse: (value: string) => T;
serialize: (value: T) => string;
};
};
export declare function createStore<T>({ storageKey, storageType, serializer, }: CreateStoreProps<T>): Store<T>;
export declare function useStore<T>(store: Store<T>, defaultValue: T): readonly [T, (next: T) => void];
export {};