Created
November 29, 2024 13:29
-
-
Save hipdev/468b0216b9736d7e31ffaf52afdf366a to your computer and use it in GitHub Desktop.
LFades Type definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { type DependencyList } from "react"; | |
export interface Atom<Value> extends Readonly<{ | |
id: string; | |
get(): Value; | |
set(value: Value): void; | |
sub(cb: SubFn<Value>): Unsub; | |
}> { | |
} | |
export type SubFn<Value> = (value: Value) => void; | |
export type Unsub = () => void; | |
export declare function atom<Value>(initialValue: Value): Atom<Value>; | |
export declare function useAtom<Value>(atom: Atom<Value>): readonly [Value, (value: Value) => void]; | |
export declare function useSubscribe<Value>(atom: Atom<Value>, cb: SubFn<Value>, deps?: DependencyList): void; | |
export declare function useHydrate(cb: () => void, deps: DependencyList): void; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment