1 | import type { Atom, Getter, WritableAtom } from 'jotai';
|
2 | declare global {
|
3 | interface SymbolConstructor {
|
4 | readonly observable: symbol;
|
5 | }
|
6 | }
|
7 | declare type Subscription = {
|
8 | unsubscribe: () => void;
|
9 | };
|
10 | declare type Observer<T> = {
|
11 | next: (value: T) => void;
|
12 | error: (error: unknown) => void;
|
13 | complete: () => void;
|
14 | };
|
15 | declare type ObservableLike<T> = {
|
16 | subscribe(observer: Observer<T>): Subscription;
|
17 | subscribe(next: (value: T) => void, error?: (error: unknown) => void, complete?: () => void): Subscription;
|
18 | [Symbol.observable]?: () => ObservableLike<T> | undefined;
|
19 | };
|
20 | declare type SubjectLike<T> = ObservableLike<T> & Observer<T>;
|
21 | declare type InitialValueFunction<T> = () => T | undefined;
|
22 | declare type AtomWithObservableOptions<TData> = {
|
23 | initialValue?: TData | InitialValueFunction<TData>;
|
24 | };
|
25 | export declare function atomWithObservable<TData>(createObservable: (get: Getter) => SubjectLike<TData>, options?: AtomWithObservableOptions<TData>): WritableAtom<TData, TData>;
|
26 | export declare function atomWithObservable<TData>(createObservable: (get: Getter) => ObservableLike<TData>, options?: AtomWithObservableOptions<TData>): Atom<TData>;
|
27 | export {};
|