UNPKG

jotai-location

Version:
24 lines (23 loc) • 914 B
import type { SetStateAction, WritableAtom } from 'jotai/vanilla'; export type Location = { pathname?: string; searchParams?: URLSearchParams; hash?: string; }; export type Options<T> = { preloaded?: T; replace?: boolean; getLocation?: () => T; applyLocation?: (location: T, options?: { replace?: boolean; }) => void; subscribe?: (callback: () => void) => () => void; }; type RequiredOptions<T> = Omit<Options<T>, 'getLocation' | 'applyLocation'> & Required<Pick<Options<T>, 'getLocation' | 'applyLocation'>>; type AtomOptions<T> = Pick<Options<T>, 'replace'>; export declare function atomWithLocation(options?: Options<Location>): WritableAtom<Location, [ SetStateAction<Location>, AtomOptions<Location>? ], void>; export declare function atomWithLocation<T>(options: RequiredOptions<T>): WritableAtom<T, [SetStateAction<T>, AtomOptions<T>?], void>; export {};