From 6736a2be7b438805a2a17a793bef8ea8e634652d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BDdzi?= Date: Mon, 20 Mar 2023 11:43:07 +0100 Subject: [PATCH] [functions] Added optional property as a third parameter to useHttpsCallable hook. Updated README.md. --- functions/README.md | 2 ++ functions/useHttpsCallable.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/README.md b/functions/README.md index 5008942..3fa13ff 100644 --- a/functions/README.md +++ b/functions/README.md @@ -27,6 +27,8 @@ The `useHttpsCallable` hook takes the following parameters: - `functions`: `functions.Functions` instance for your Firebase app - `name`: A `string` representing the name of the function to call +- `options`: An optional `object` with the following properties: + - `timeout`: A `number` representing the timeout in milliseconds for the function call. Default is 70000 ms. Returns: diff --git a/functions/useHttpsCallable.ts b/functions/useHttpsCallable.ts index 28b14f6..ec5da8f 100644 --- a/functions/useHttpsCallable.ts +++ b/functions/useHttpsCallable.ts @@ -2,6 +2,7 @@ import { Functions, httpsCallable, HttpsCallableResult, + HttpsCallableOptions, } from 'firebase/functions'; import { useCallback, useState } from 'react'; @@ -20,7 +21,8 @@ export type HttpsCallableHook< export default ( functions: Functions, - name: string + name: string, + options?: HttpsCallableOptions, ): HttpsCallableHook => { const [error, setError] = useState(); const [loading, setLoading] = useState(false); @@ -31,7 +33,8 @@ export default ( ): Promise | undefined> => { const callable = httpsCallable( functions, - name + name, + options, ); setLoading(true); setError(undefined);