Skip to content

Instantly share code, notes, and snippets.

@hipdev
Created November 29, 2024 13:29
Show Gist options
  • Save hipdev/468b0216b9736d7e31ffaf52afdf366a to your computer and use it in GitHub Desktop.
Save hipdev/468b0216b9736d7e31ffaf52afdf366a to your computer and use it in GitHub Desktop.
LFades Type definitions
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