UNPKG

861 BTypeScriptView Raw
1import React from 'react';
2import { Atom, WritableAtom, AnyAtom } from './types';
3import { ImmutableMap } from './immutableMap';
4export declare type AtomState<Value = unknown> = {
5 readE?: Error;
6 readP?: Promise<void>;
7 writeP?: Promise<void>;
8 value?: Value;
9};
10declare type State = ImmutableMap<AnyAtom, AtomState>;
11export declare type Actions = {
12 add: <Value>(id: symbol, atom: Atom<Value>) => void;
13 del: (id: symbol) => void;
14 read: <Value>(state: State, atom: Atom<Value>) => AtomState<Value>;
15 write: <Value, Update>(atom: WritableAtom<Value, Update>, update: Update) => void | Promise<void>;
16};
17export declare const ActionsContext: React.Context<Actions>;
18export declare const StateContext: React.Context<ImmutableMap<Atom<unknown>, AtomState<unknown>>>;
19export declare const Provider: React.FC;
20export {};