@@ -12,20 +12,21 @@ import { useListen, UseListenOnChange } from "../internal/useListen.js";
1212import { LoadingState } from "../internal/useLoadingValue.js" ;
1313import { isDocRefEqual } from "./internal.js" ;
1414
15- export type UseDocumentDataResult < Value extends DocumentData = DocumentData > = ValueHookResult < Value , FirestoreError > ;
15+ export type UseDocumentDataResult < AppModelType = DocumentData > = ValueHookResult < AppModelType , FirestoreError > ;
1616
1717/**
1818 * Options to configure the subscription
1919 */
20- export interface UseDocumentDataOptions < Value extends DocumentData = DocumentData > {
20+ export interface UseDocumentDataOptions < AppModelType = DocumentData > {
2121 snapshotListenOptions ?: SnapshotListenOptions ;
2222 snapshotOptions ?: SnapshotOptions ;
23- initialValue ?: Value ;
23+ initialValue ?: AppModelType ;
2424}
2525
2626/**
2727 * Returns and updates the data of a Firestore DocumentReference
28- * @template Value Type of the document data
28+ * @template AppModelType Shape of the data after it was converted from firestore
29+ * @template DbModelType Shape of the data in firestore
2930 * @param reference Firestore DocumentReference that will be subscribed to
3031 * @param options Options to configure the subscription
3132 * `initialValue`: Value that is returned while the document is being fetched.
@@ -34,17 +35,21 @@ export interface UseDocumentDataOptions<Value extends DocumentData = DocumentDat
3435 * - loading: `true` while fetching the document; `false` if the document was fetched successfully or an error occurred
3536 * - error: `undefined` if no error occurred
3637 */
37- export function useDocumentData < Value extends DocumentData = DocumentData > (
38- reference : DocumentReference < Value > | undefined | null ,
39- options ?: UseDocumentDataOptions < Value > ,
40- ) : UseDocumentDataResult < Value > {
38+ export function useDocumentData < AppModelType = DocumentData , DbModelType extends DocumentData = DocumentData > (
39+ reference : DocumentReference < AppModelType , DbModelType > | undefined | null ,
40+ options ?: UseDocumentDataOptions < AppModelType > ,
41+ ) : UseDocumentDataResult < AppModelType > {
4142 const { snapshotListenOptions, snapshotOptions } = options ?? { } ;
4243 const { includeMetadataChanges } = snapshotListenOptions ?? { } ;
4344 const { serverTimestamps } = snapshotOptions ?? { } ;
4445
45- const onChange : UseListenOnChange < Value , FirestoreError , DocumentReference < Value > > = useCallback (
46+ const onChange : UseListenOnChange <
47+ AppModelType ,
48+ FirestoreError ,
49+ DocumentReference < AppModelType , DbModelType >
50+ > = useCallback (
4651 ( stableRef , next , error ) =>
47- onSnapshot < Value > (
52+ onSnapshot (
4853 stableRef ,
4954 { includeMetadataChanges } ,
5055 {
0 commit comments