react-firehooks
Version:
Lightweight dependency-free collection of React hooks for Firebase
14 lines (13 loc) • 1.02 kB
TypeScript
import type { AggregateSpec, AggregateSpecData, FirestoreError, Query } from "firebase/firestore";
import type { ValueHookResult } from "../common/types.js";
export type UseAggregateFromServerResult<T extends AggregateSpec> = ValueHookResult<AggregateSpecData<T>, FirestoreError>;
/**
* Returns aggregate of a Firestore Query. Does not update the result once initially calculated.
* @param query Firestore query the aggregate is calculated for
* @param aggregateSpec Aggregate specification
* @returns Size of the result set, loading state, and error
* - value: Aggregate of the Firestore query; `undefined` if the aggregate is currently being calculated, or an error occurred
* - loading: `true` while calculating the aggregate; `false` if the aggregate was calculated successfully or an error occurred
* - error: `undefined` if no error occurred
*/
export declare function useAggregateFromServer<T extends AggregateSpec>(query: Query<unknown> | undefined | null, aggregateSpec: T): UseAggregateFromServerResult<T>;