1 | import { Atom, WritableAtom, AnyAtom, OnUnmount } from './types';
|
2 | declare type Revision = number;
|
3 | declare type ReadDependencies = Map<AnyAtom, Revision>;
|
4 | export declare type AtomState<Value = unknown> = {
|
5 | re?: Error;
|
6 | rp?: Promise<void>;
|
7 | wp?: Promise<void>;
|
8 | v?: Value;
|
9 | r: Revision;
|
10 | d: ReadDependencies;
|
11 | };
|
12 | declare type AtomStateMap = WeakMap<AnyAtom, AtomState>;
|
13 | declare type UseAtomSymbol = symbol;
|
14 | declare type Dependents = Set<AnyAtom | UseAtomSymbol>;
|
15 | declare type MountedMap = Map<AnyAtom, [
|
16 | Dependents,
|
17 | OnUnmount | void
|
18 | ]>;
|
19 | declare type WorkInProgress = Map<AnyAtom, AtomState>;
|
20 | export declare type UpdateState = (updater: (prev: State) => State) => void;
|
21 | export declare type State = {
|
22 | a: AtomStateMap;
|
23 | m: MountedMap;
|
24 | w: WorkInProgress;
|
25 | };
|
26 | export declare const createState: (initialValues?: Iterable<readonly [
|
27 | Atom<unknown>,
|
28 | unknown
|
29 | ]> | undefined) => State;
|
30 | export declare const readAtom: <Value>(state: State, updateState: UpdateState, readingAtom: Atom<Value>) => AtomState<Value>;
|
31 | export declare const addAtom: (updateState: UpdateState, addingAtom: AnyAtom, useId: symbol) => void;
|
32 | export declare const delAtom: (updateState: UpdateState, deletingAtom: AnyAtom, useId: symbol) => void;
|
33 | export declare const writeAtom: <Value, Update>(updateState: UpdateState, writingAtom: WritableAtom<Value, Update>, update: Update) => void | Promise<void>;
|
34 | export {};
|