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
In `app.module.ts` I put in commented out lines anticipating AngularFire 7. When AngularFire 7 is available for callable functions we can easily update the documentation with a few clicks.
I also put in two lines showing how to run your functions in the Firebase emulator. I clearly indicated how to comment out these lines to run your functions in the cloud.
I made an HTML view to show how to handle user input. Also I added a second set of curly brackets to `{{ data$ | async }}`. This is necessary to make the code run without throwing errors.
In `app.component.ts` I put in lines anticipating AngularFire 7.
I moved the template to an HTML view.
I added a variable `data$` to handle the data returned from the cloud function. I added `this` to `fns.httpsCallable('my-fn-name');`. These changes are necessary to make the code run without throwing errors.
I changed `fns` to `functions` for readability.
I made two functions, one that executes on page load and the user executes on user input.
I put in the `index.js` file showing the cloud functions. The old documentation was confusing as to what data went from Angular to the cloud function and what data was returned from the cloud function. Showing the `index.js` functions clarifies this.
I've written a longer tutorial at https://github.com/tdkehoe/Firebase-Cloud-Functions-with-Angular/blob/main/README.md.
When can we expect to use AngularFire 7 with callable functions?
Copy file name to clipboardExpand all lines: docs/functions/functions.md
+97-10Lines changed: 97 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -7,25 +7,58 @@
7
7
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.
61
+
29
62
### Injecting the AngularFireFunctions service
30
63
31
64
Once the `AngularFireFunctionsModule` is registered you can inject the `AngularFireFunctions` service.
@@ -50,25 +83,79 @@ AngularFireFunctions is super easy. You create a function on the server side and
50
83
| method ||
51
84
| ---------|--------------------|
52
85
|`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.
119
+
120
+
The component handles two functions, one that executes on page load and another that executes on user input.
121
+
70
122
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.
71
123
124
+
### Make your callable cloud functions
125
+
126
+
```js
127
+
// 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.
154
+
155
+
Both functions use `https.onCall((data, context) => {})`, which makes a function callable from Angular.
156
+
157
+
`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