-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add docs for functions Co-authored-by: David East <[email protected]>
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# RxFire Cloud Functions | ||
|
||
## Callable Functions Observables | ||
|
||
### `httpsCallable()` | ||
|
||
The `httpsCallable()` function returns an observable that calls a [callable function](https://firebase.google.com/docs/functions/callable), then emits the data returned from that function. | ||
|
||
| | | | ||
| --------------- | ------------------------------------------------------------------------ | | ||
| **function** | `httpsCallable()` | | ||
| **params** | `functions: Functions`, `name: string`, `options?: HttpsCallableOptions` | | ||
| **import path** | `rxfire/functions` | | ||
| **return** | `(data: T) => Observable<R>` | | ||
|
||
#### TypeScript Example | ||
|
||
```ts | ||
import { httpsCallable } from "rxfire/functions"; | ||
import { initializeApp } from "firebase/app"; | ||
import { getFunctions } from "firebase/functions"; | ||
|
||
// Set up Firebase | ||
const app = initializeApp({ | ||
/* config */ | ||
}); | ||
const functions = getFunctions(app); | ||
|
||
// Assume an `uppercaser` function is deployed | ||
const capitalizedText$ = httpsCallable<string, string>(functions, "uppercaser")("hello world"); | ||
capitalizedText$.subscribe((text) => { | ||
console.log(text); | ||
}); // logs "HELLO WORLD" | ||
``` |