1 | import type { Atom, Getter, WritableAtom } from 'jotai/vanilla';
|
2 | type AnyError = unknown;
|
3 | declare global {
|
4 | interface SymbolConstructor {
|
5 | readonly observable: symbol;
|
6 | }
|
7 | }
|
8 | type Subscription = {
|
9 | unsubscribe: () => void;
|
10 | };
|
11 | type Observer<T> = {
|
12 | next: (value: T) => void;
|
13 | error: (error: AnyError) => void;
|
14 | complete: () => void;
|
15 | };
|
16 | type ObservableLike<T> = {
|
17 | [Symbol.observable]?: () => ObservableLike<T> | undefined;
|
18 | } & ({
|
19 | subscribe(observer: Observer<T>): Subscription;
|
20 | } | {
|
21 | subscribe(observer: Partial<Observer<T>>): Subscription;
|
22 | } | {
|
23 | subscribe(observer: Partial<Observer<T>>): Subscription;
|
24 | subscribe(next: (value: T) => void): Subscription;
|
25 | });
|
26 | type SubjectLike<T> = ObservableLike<T> & Observer<T>;
|
27 | type Options<Data> = {
|
28 | initialValue?: Data | (() => Data);
|
29 | unstable_timeout?: number;
|
30 | };
|
31 | type OptionsWithInitialValue<Data> = {
|
32 | initialValue: Data | (() => Data);
|
33 | unstable_timeout?: number;
|
34 | };
|
35 | export declare function atomWithObservable<Data>(getObservable: (get: Getter) => SubjectLike<Data>, options: OptionsWithInitialValue<Data>): WritableAtom<Data, [Data], void>;
|
36 | export declare function atomWithObservable<Data>(getObservable: (get: Getter) => SubjectLike<Data>, options?: Options<Data>): WritableAtom<Data | Promise<Data>, [Data], void>;
|
37 | export declare function atomWithObservable<Data>(getObservable: (get: Getter) => ObservableLike<Data>, options: OptionsWithInitialValue<Data>): Atom<Data>;
|
38 | export declare function atomWithObservable<Data>(getObservable: (get: Getter) => ObservableLike<Data>, options?: Options<Data>): Atom<Data | Promise<Data>>;
|
39 | export {};
|
40 |
|
\ | No newline at end of file |