You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/compat/functions/functions.md
+97-10Lines changed: 97 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -9,25 +9,58 @@
9
9
Cloud Functions for AngularFire is contained in the `@angular/fire/functions` module namespace. Import the `AngularFireFunctionsModule` in your `NgModule`. This sets up the `AngularFireFunction` service for dependency injection.
This view has a button for user input and displays the data returned from the cloud function.
63
+
31
64
### Injecting the AngularFireFunctions service
32
65
33
66
Once the `AngularFireFunctionsModule` is registered you can inject the `AngularFireFunctions` service.
@@ -52,25 +85,79 @@ AngularFireFunctions is super easy. You create a function on the server side and
52
85
| method ||
53
86
| ---------|--------------------|
54
87
|`httpCallable(name: string): (data: T) `| Creates a callable function based on a function name. Returns a function that can create the observable of the http call. |
`data$` handles the data returned from the cloud function and displays the data in the view.
121
+
122
+
The component handles two functions, one that executes on page load and another that executes on user input.
123
+
72
124
Notice that calling `httpsCallable()` does not initiate the request. It creates a function, which when called creates an Observable, subscribe or convert it to a Promise to initiate the request.
73
125
126
+
### Make your callable cloud functions
127
+
128
+
```js
129
+
// The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
The first function executes when the page loads. The second function executes from user input.
156
+
157
+
Both functions use `https.onCall((data, context) => {})`, which makes a function callable from Angular.
158
+
159
+
`data` is the data sent from Angular. `context` is metadata about the function executing. The returned data (`22`, `57`) goes back to Angular and is displayed in the view. This data is an Observable.
0 commit comments