UNPKG

1.65 kBTypeScriptView Raw
1import { Observable } from 'rxjs';
2import { SuspenseSubject } from './SuspenseSubject';
3import { ReactFireOptions } from './';
4export declare function preloadObservable<T>(source: Observable<T>, id: string): SuspenseSubject<T>;
5export interface ObservableStatus<T> {
6 /**
7 * The loading status.
8 *
9 * - `loading`: Waiting for the first value from an observable
10 * - `error`: Something went wrong. Check `ObservableStatus.error` for more details
11 * - `success`: The hook has emitted at least one value
12 *
13 * If `initialData` is passed in, this will skip `loading` and go straight to `success`.
14 */
15 status: 'loading' | 'error' | 'success';
16 /**
17 * Indicates whether the hook has emitted a value at some point
18 *
19 * If `initialData` is passed in, this will be `true`.
20 */
21 hasEmitted: boolean;
22 /**
23 * If this is `true`, the hook will be emitting no further items.
24 */
25 isComplete: boolean;
26 /**
27 * The most recent value.
28 *
29 * If `initialData` is passed in, the first value of `data` will be the valuea provided in `initialData` **UNLESS** the underlying observable is ready, in which case it will skip `initialData`.
30 */
31 data: T;
32 /**
33 * Any error that may have occurred in the underlying observable
34 */
35 error: Error | undefined;
36 /**
37 * Promise that resolves after first emit from observable
38 */
39 firstValuePromise: Promise<void>;
40}
41export declare function useObservable<T = unknown>(observableId: string, source: Observable<T>, config?: ReactFireOptions): ObservableStatus<T>;