-
Notifications
You must be signed in to change notification settings - Fork 308
/
Copy pathtypes.ts
61 lines (58 loc) · 1.48 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {
DocumentData,
DocumentSnapshot,
FirestoreError,
QuerySnapshot,
SnapshotListenOptions,
SnapshotOptions,
} from 'firebase/firestore';
import { LoadingHook } from '../util';
export type IDOptions<T> = {
snapshotOptions?: SnapshotOptions;
};
export type Options = {
snapshotListenOptions?: SnapshotListenOptions;
};
export type InitialValueOptions<T> = {
initialValue?: T;
};
export type DataOptions<T> = Options & IDOptions<T>;
export type OnceOptions = {
getOptions?: GetOptions;
};
export type GetOptions = {
source?: 'default' | 'server' | 'cache';
};
export type OnceDataOptions<T> = OnceOptions & IDOptions<T>;
export type CollectionHook<T = DocumentData> = LoadingHook<
QuerySnapshot<T>,
FirestoreError
>;
export type CollectionOnceHook<T = DocumentData> = [
...CollectionHook<T>,
() => Promise<void>
];
export type CollectionDataHook<T = DocumentData> = [
...LoadingHook<T[], FirestoreError>,
QuerySnapshot<T> | undefined
];
export type CollectionDataOnceHook<T = DocumentData> = [
...CollectionDataHook<T>,
() => Promise<void>
];
export type DocumentHook<T = DocumentData> = LoadingHook<
DocumentSnapshot<T>,
FirestoreError
>;
export type DocumentOnceHook<T = DocumentData> = [
...DocumentHook<T>,
() => Promise<void>
];
export type DocumentDataHook<T = DocumentData> = [
...LoadingHook<T, FirestoreError>,
DocumentSnapshot<T> | undefined
];
export type DocumentDataOnceHook<T = DocumentData> = [
...DocumentDataHook<T>,
() => Promise<void>
];