@angular/fire 7.5.0 → 7.6.0-canary.34e89a4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -74
- package/analytics/is-analytics-supported-factory.d.ts +4 -0
- package/bundles/angular-fire-analytics.umd.js +41 -31
- package/bundles/angular-fire-analytics.umd.js.map +1 -1
- package/bundles/angular-fire-app-check.umd.js +14 -18
- package/bundles/angular-fire-app-check.umd.js.map +1 -1
- package/bundles/angular-fire-app.umd.js +14 -18
- package/bundles/angular-fire-app.umd.js.map +1 -1
- package/bundles/angular-fire-auth-guard.umd.js +5 -7
- package/bundles/angular-fire-auth-guard.umd.js.map +1 -1
- package/bundles/angular-fire-auth.umd.js +64 -68
- package/bundles/angular-fire-auth.umd.js.map +1 -1
- package/bundles/angular-fire-compat-analytics.umd.js +11 -13
- package/bundles/angular-fire-compat-analytics.umd.js.map +1 -1
- package/bundles/angular-fire-compat-auth-guard.umd.js +6 -8
- package/bundles/angular-fire-compat-auth-guard.umd.js.map +1 -1
- package/bundles/angular-fire-compat-auth.umd.js +11 -13
- package/bundles/angular-fire-compat-auth.umd.js.map +1 -1
- package/bundles/angular-fire-compat-database.umd.js +9 -11
- package/bundles/angular-fire-compat-database.umd.js.map +1 -1
- package/bundles/angular-fire-compat-firestore.umd.js +9 -11
- package/bundles/angular-fire-compat-firestore.umd.js.map +1 -1
- package/bundles/angular-fire-compat-functions.umd.js +9 -11
- package/bundles/angular-fire-compat-functions.umd.js.map +1 -1
- package/bundles/angular-fire-compat-messaging.umd.js +8 -10
- package/bundles/angular-fire-compat-messaging.umd.js.map +1 -1
- package/bundles/angular-fire-compat-performance.umd.js +8 -10
- package/bundles/angular-fire-compat-performance.umd.js.map +1 -1
- package/bundles/angular-fire-compat-remote-config.umd.js +9 -11
- package/bundles/angular-fire-compat-remote-config.umd.js.map +1 -1
- package/bundles/angular-fire-compat-storage.umd.js +8 -10
- package/bundles/angular-fire-compat-storage.umd.js.map +1 -1
- package/bundles/angular-fire-compat.umd.js +13 -15
- package/bundles/angular-fire-compat.umd.js.map +1 -1
- package/bundles/angular-fire-database.umd.js +59 -67
- package/bundles/angular-fire-database.umd.js.map +1 -1
- package/bundles/angular-fire-firestore-lite.umd.js +50 -54
- package/bundles/angular-fire-firestore-lite.umd.js.map +1 -1
- package/bundles/angular-fire-firestore.umd.js +67 -71
- package/bundles/angular-fire-firestore.umd.js.map +1 -1
- package/bundles/angular-fire-functions.umd.js +15 -19
- package/bundles/angular-fire-functions.umd.js.map +1 -1
- package/bundles/angular-fire-messaging.umd.js +33 -23
- package/bundles/angular-fire-messaging.umd.js.map +1 -1
- package/bundles/angular-fire-performance.umd.js +17 -21
- package/bundles/angular-fire-performance.umd.js.map +1 -1
- package/bundles/angular-fire-remote-config.umd.js +47 -37
- package/bundles/angular-fire-remote-config.umd.js.map +1 -1
- package/bundles/angular-fire-storage.umd.js +27 -31
- package/bundles/angular-fire-storage.umd.js.map +1 -1
- package/bundles/angular-fire.umd.js +16 -59
- package/bundles/angular-fire.umd.js.map +1 -1
- package/compat/firestore/interfaces.d.ts +4 -4
- package/core.d.ts +1 -12
- package/docs/analytics.md +67 -0
- package/docs/app-check.md +53 -0
- package/docs/auth.md +165 -0
- package/docs/{analytics → compat/analytics}/getting-started.md +2 -0
- package/docs/{auth → compat/auth}/getting-started.md +2 -0
- package/docs/{auth → compat/auth}/router-guards.md +2 -0
- package/docs/{emulators → compat/emulators}/emulators.md +2 -0
- package/docs/{firestore → compat/firestore}/collections.md +2 -0
- package/docs/{firestore → compat/firestore}/documents.md +2 -0
- package/docs/{firestore → compat/firestore}/offline-data.md +2 -0
- package/docs/{firestore → compat/firestore}/querying-collections.md +2 -0
- package/docs/{functions → compat/functions}/functions.md +2 -0
- package/docs/{messaging → compat/messaging}/messaging.md +2 -0
- package/docs/{performance → compat/performance}/getting-started.md +2 -0
- package/docs/{remote-config → compat/remote-config}/getting-started.md +2 -0
- package/docs/{rtdb → compat/rtdb}/lists.md +2 -0
- package/docs/{rtdb → compat/rtdb}/objects.md +2 -0
- package/docs/{rtdb → compat/rtdb}/querying-lists.md +2 -0
- package/docs/{storage → compat/storage}/storage.md +2 -0
- package/docs/compat.md +70 -0
- package/docs/database.md +175 -0
- package/docs/deploy/getting-started.md +2 -2
- package/docs/firestore.md +148 -0
- package/docs/functions.md +52 -0
- package/docs/images/analytics-illo_1x.png +0 -0
- package/docs/images/auth-illo_1x.png +0 -0
- package/docs/images/cloud-messaging-illo_1x.png +0 -0
- package/docs/images/database-illo_1x.png +0 -0
- package/docs/images/firestore-illo_1x.png +0 -0
- package/docs/images/functions-illo_1x.png +0 -0
- package/docs/images/hosting-illo_1x.png +0 -0
- package/docs/images/performance-illo_1x.png +0 -0
- package/docs/images/reCAPTCHA-logo@1x.png +0 -0
- package/docs/images/remote-config-illo_1x.png +0 -0
- package/docs/images/storage-illo_1x.png +0 -0
- package/docs/install-and-setup.md +39 -86
- package/docs/install-firebase-tools.md +78 -0
- package/docs/messaging.md +25 -0
- package/docs/performance.md +57 -0
- package/docs/remote-config.md +53 -0
- package/docs/storage.md +90 -0
- package/docs/universal/cloud-functions.md +27 -6
- package/docs/universal/getting-started.md +9 -134
- package/esm2015/analytics/analytics.module.js +7 -6
- package/esm2015/analytics/is-analytics-supported-factory.js +16 -0
- package/esm2015/analytics/overrides.js +3 -3
- package/esm2015/compat/firestore/interfaces.js +1 -1
- package/esm2015/core.js +3 -45
- package/esm2015/messaging/is-messaging-supported-factory.js +16 -0
- package/esm2015/messaging/messaging.module.js +7 -6
- package/esm2015/messaging/overrides.js +3 -3
- package/esm2015/remote-config/is-remote-config-supported-factory.js +16 -0
- package/esm2015/remote-config/overrides.js +3 -3
- package/esm2015/remote-config/remote-config.module.js +7 -6
- package/fesm2015/angular-fire-analytics.js +21 -7
- package/fesm2015/angular-fire-analytics.js.map +1 -1
- package/fesm2015/angular-fire-app-check.js.map +1 -1
- package/fesm2015/angular-fire-app.js.map +1 -1
- package/fesm2015/angular-fire-auth-guard.js.map +1 -1
- package/fesm2015/angular-fire-auth.js.map +1 -1
- package/fesm2015/angular-fire-compat-analytics.js.map +1 -1
- package/fesm2015/angular-fire-compat-auth-guard.js.map +1 -1
- package/fesm2015/angular-fire-compat-auth.js.map +1 -1
- package/fesm2015/angular-fire-compat-database.js +1 -1
- package/fesm2015/angular-fire-compat-database.js.map +1 -1
- package/fesm2015/angular-fire-compat-firestore.js +1 -1
- package/fesm2015/angular-fire-compat-firestore.js.map +1 -1
- package/fesm2015/angular-fire-compat-functions.js.map +1 -1
- package/fesm2015/angular-fire-compat-messaging.js.map +1 -1
- package/fesm2015/angular-fire-compat-performance.js.map +1 -1
- package/fesm2015/angular-fire-compat-remote-config.js.map +1 -1
- package/fesm2015/angular-fire-compat-storage.js.map +1 -1
- package/fesm2015/angular-fire-compat.js.map +1 -1
- package/fesm2015/angular-fire-database.js.map +1 -1
- package/fesm2015/angular-fire-firestore-lite.js.map +1 -1
- package/fesm2015/angular-fire-firestore.js.map +1 -1
- package/fesm2015/angular-fire-functions.js.map +1 -1
- package/fesm2015/angular-fire-messaging.js +21 -7
- package/fesm2015/angular-fire-messaging.js.map +1 -1
- package/fesm2015/angular-fire-performance.js.map +1 -1
- package/fesm2015/angular-fire-remote-config.js +22 -8
- package/fesm2015/angular-fire-remote-config.js.map +1 -1
- package/fesm2015/angular-fire-storage.js.map +1 -1
- package/fesm2015/angular-fire.js +3 -45
- package/fesm2015/angular-fire.js.map +1 -1
- package/messaging/is-messaging-supported-factory.d.ts +4 -0
- package/package.json +9 -10
- package/remote-config/is-remote-config-supported-factory.d.ts +4 -0
- package/schematics/deploy/actions.js +8 -3
- package/schematics/deploy/builder.js +2 -2
- package/schematics/firebaseTools.js +4 -2
- package/schematics/setup/index.js +58 -29
- package/schematics/setup/prompts.js +18 -46
- package/schematics/utils.js +32 -28
- package/docs/ionic/authentication.md +0 -104
- package/docs/ionic/cli.md +0 -218
- package/docs/ionic/v2.md +0 -531
- package/docs/ionic/v3.md +0 -705
- package/schematics/setup/ssr.js +0 -100
- package/schematics/setup/static.js +0 -78
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/firestore-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Firestore
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Firestore
|
|
8
|
+
|
|
9
|
+
Cloud Firestore is a flexible, scalable NoSQL database for mobile, web, and server development from Firebase and Google Cloud. It keeps your data in sync across client apps through realtime listeners and offers offline support for mobile and web so you can build responsive apps that work regardless of network latency or Internet connectivity.
|
|
10
|
+
|
|
11
|
+
[Learn more](https://firebase.google.com/docs/firestore)
|
|
12
|
+
|
|
13
|
+
Cloud Firestore is the API that gives your application access to your database in the cloud or locally in your [emulator](https://firebase.google.com/docs/emulator-suite).
|
|
14
|
+
|
|
15
|
+
## Dependency Injection
|
|
16
|
+
|
|
17
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
18
|
+
```bash
|
|
19
|
+
ng add @angular/fire
|
|
20
|
+
```
|
|
21
|
+
Provide a Firestore instance in the application's `NgModule` (`app.module.ts`):
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
@NgModule({
|
|
25
|
+
declarations: [
|
|
26
|
+
...
|
|
27
|
+
],
|
|
28
|
+
imports: [
|
|
29
|
+
...
|
|
30
|
+
// App initialization
|
|
31
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
32
|
+
provideFirestore(() => getFirestore())
|
|
33
|
+
],
|
|
34
|
+
providers: [],
|
|
35
|
+
bootstrap: [AppComponent]
|
|
36
|
+
})
|
|
37
|
+
export class AppModule { }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
In your component class, for example `user-profile.component.ts` import and inject `Firestore`:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Component, inject } from '@angular/core';
|
|
45
|
+
import { Firestore } from '@angular/fire/firestore';
|
|
46
|
+
|
|
47
|
+
@Component({
|
|
48
|
+
standalone: true,
|
|
49
|
+
selector: 'app-user-profile',
|
|
50
|
+
...
|
|
51
|
+
})
|
|
52
|
+
export class UserProfileComponent {
|
|
53
|
+
private firestore: Firestore = inject(Firestore);
|
|
54
|
+
...
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Firebase API
|
|
59
|
+
With the reference to Cloud Firestore available in a component it is now possible to connect read from and write to the database.
|
|
60
|
+
|
|
61
|
+
### Reading data
|
|
62
|
+
In Cloud Firestore data is stored in `documents` and `documents` are stored in `collections`. The path to data follows `<collection_name>/<document_id>` and continues if there are subcollections. For example, `"users/ABC12345/posts/XYZ6789"` represents:
|
|
63
|
+
* `users` collection
|
|
64
|
+
* document id `ABC12345`
|
|
65
|
+
* `posts` collection
|
|
66
|
+
* document id `XYZ6789`
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Let's explore reading data in Angular using the `collection` and `collectionData` functions.
|
|
70
|
+
|
|
71
|
+
In `user-profile.component.ts`:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { Firestore, collection, collectionData} from '@angular/fire/firestore';
|
|
75
|
+
import { Component, inject } from '@angular/core';
|
|
76
|
+
|
|
77
|
+
@Component ({
|
|
78
|
+
selector: 'app-user-profile',
|
|
79
|
+
standalone: true,
|
|
80
|
+
...
|
|
81
|
+
})
|
|
82
|
+
export class UserProfileComponent {
|
|
83
|
+
private firestore: Firestore = inject(Firestore); // inject Cloud Firestore
|
|
84
|
+
users$: Observable<UserProfile[]>;
|
|
85
|
+
|
|
86
|
+
constructor() {
|
|
87
|
+
// get a reference to the user-profile collection
|
|
88
|
+
const userProfileCollection = collection(this.firestore, 'users');
|
|
89
|
+
|
|
90
|
+
// get documents (data) from the collection using collectionData
|
|
91
|
+
this.users$ = collectionData(userProfileCollection) as Observable<UserProfile[]>;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export Interface UserProfile {
|
|
95
|
+
username: string;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
`collectionData` returns an `observable` that can we can use to display the data in the template. In `user-profile.component.html`:
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<section>
|
|
102
|
+
<h1>User Profiles</h1>
|
|
103
|
+
<ul>
|
|
104
|
+
<li *ngFor="let user of users$ | async">
|
|
105
|
+
{{user.username}}
|
|
106
|
+
</li>
|
|
107
|
+
</ul>
|
|
108
|
+
</section>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The `async` pipe handles unsubscribing from observables.
|
|
112
|
+
|
|
113
|
+
### Writing data
|
|
114
|
+
To write to Cloud Firestore use the `addDoc` function. It will create a new document at the path specified by the collection. In `user-profile.component.ts`, we'll update the code to add a new document on a `<button>` click.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { Firestore, collection, collectionData, addDoc} from '@angular/fire/firestore';
|
|
119
|
+
import { Component, inject } from '@angular/core';
|
|
120
|
+
|
|
121
|
+
@Component ({
|
|
122
|
+
selector: 'app-user-profile',
|
|
123
|
+
standalone: true,
|
|
124
|
+
...
|
|
125
|
+
})
|
|
126
|
+
export class UserProfileComponent {
|
|
127
|
+
private firestore: Firestore = inject(Firestore); // inject Cloud Firestore
|
|
128
|
+
users$: Observable<UserProfile[]>;
|
|
129
|
+
usersCollection: CollectionReference;
|
|
130
|
+
|
|
131
|
+
constructor() {...}
|
|
132
|
+
|
|
133
|
+
addUserProfile(username: string) {
|
|
134
|
+
if (!username) return;
|
|
135
|
+
|
|
136
|
+
addDoc(this.usersCollection, <UserProfile> { username }).then((documentReference: DocumentReference) => {
|
|
137
|
+
// the documentReference provides access to the newly created document
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export Interface UserProfile {
|
|
142
|
+
username: string;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
In the `addUserProfile` method we use a reference to the `this.usersCollection` and provide `UserProfile` data to the the `addDoc` function. `addDoc` returns a promise that can be used to respond to the successful addition of the data. Errors can also be caught here.
|
|
146
|
+
|
|
147
|
+
## Learn More
|
|
148
|
+
More information on API methods and other functions can be found on the [Firebase Official Docs](https://firebase.google.com/docs/reference/js/firestore_)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/functions-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Functions
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Functions
|
|
8
|
+
|
|
9
|
+
The Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/functions/get-started)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
16
|
+
```bash
|
|
17
|
+
ng add @angular/fire
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide a Cloud Functions instance in the application's `NgModule` (`app.module.ts`):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
+
import { getFunctions, provideFunctions } from '@angular/fire/functions';
|
|
25
|
+
|
|
26
|
+
@NgModule({
|
|
27
|
+
imports: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
29
|
+
provideFunctions(() => getFunctions()),
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject it into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { Functions } from '@angular/fire/functions';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class AppComponent {
|
|
42
|
+
private functions: Functions = inject(Functions);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
The [Firebase API for Cloud Functions documentation](https://firebase.google.com/docs/reference/js/functions) is available on the Firebase website.
|
|
49
|
+
|
|
50
|
+
## Convenience observables
|
|
51
|
+
|
|
52
|
+
More details coming soon.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
### 1. Create a new project
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
+
# Using yarn create
|
|
7
|
+
yarn create @angular <project-name>
|
|
8
|
+
cd <project-name>
|
|
9
|
+
```
|
|
10
|
+
or
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Using npm create
|
|
14
|
+
npm create @angular <project-name>
|
|
15
|
+
cd <project-name>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
optionally installing the tooling directly:
|
|
19
|
+
```bash
|
|
20
|
+
# Installing the tooling directly
|
|
6
21
|
npm install -g @angular/cli
|
|
7
22
|
ng new <project-name>
|
|
8
23
|
cd <project-name>
|
|
@@ -16,85 +31,18 @@ The Angular CLI's `new` command will set up the latest Angular build in a new pr
|
|
|
16
31
|
ng add @angular/fire
|
|
17
32
|
```
|
|
18
33
|
|
|
19
|
-
Now that you have a new project setup, install AngularFire and Firebase from npm.
|
|
20
|
-
|
|
21
|
-
### 3. Add Firebase config to environments variable
|
|
22
|
-
|
|
23
|
-
Open `/src/environments/environment.ts` and add your Firebase configuration. You can find your project configuration in [the Firebase Console](https://console.firebase.google.com). Click the Gear icon next to Project Overview, in the Your Apps section, create a new app and choose the type Web. Give the app a name and copy the config values provided.
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
export const environment = {
|
|
27
|
-
production: false,
|
|
28
|
-
firebase: {
|
|
29
|
-
apiKey: '<your-key>',
|
|
30
|
-
authDomain: '<your-project-authdomain>',
|
|
31
|
-
databaseURL: '<your-database-URL>',
|
|
32
|
-
projectId: '<your-project-id>',
|
|
33
|
-
storageBucket: '<your-storage-bucket>',
|
|
34
|
-
messagingSenderId: '<your-messaging-sender-id>',
|
|
35
|
-
appId: '<your-app-id>',
|
|
36
|
-
measurementId: '<your-measurement-id>'
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 4. Setup `@NgModule` for the `AngularFireModule`
|
|
42
|
-
|
|
43
|
-
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
47
|
-
import { NgModule } from '@angular/core';
|
|
48
|
-
import { AppComponent } from './app.component';
|
|
49
|
-
import { AngularFireModule } from '@angular/fire/compat';
|
|
50
|
-
import { environment } from '../environments/environment';
|
|
51
|
-
|
|
52
|
-
@NgModule({
|
|
53
|
-
imports: [
|
|
54
|
-
BrowserModule,
|
|
55
|
-
AngularFireModule.initializeApp(environment.firebase)
|
|
56
|
-
],
|
|
57
|
-
declarations: [ AppComponent ],
|
|
58
|
-
bootstrap: [ AppComponent ]
|
|
59
|
-
})
|
|
60
|
-
export class AppModule {}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 5. Setup individual `@NgModule`s
|
|
34
|
+
Now that you have a new project setup, install AngularFire and Firebase from npm. This will complete the following tasks:
|
|
64
35
|
|
|
65
|
-
|
|
36
|
+
1. Add Firebase config to environments variables
|
|
37
|
+
2. Configure `@NgModule` for the `AngularFireModule`
|
|
66
38
|
|
|
67
|
-
|
|
39
|
+
### 3. Inject `Firestore`
|
|
68
40
|
|
|
69
|
-
|
|
70
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
71
|
-
import { NgModule } from '@angular/core';
|
|
72
|
-
import { AppComponent } from './app.component';
|
|
73
|
-
import { AngularFireModule } from '@angular/fire/compat';
|
|
74
|
-
import { AngularFireAnalyticsModule } from '@angular/fire/compat/analytics';
|
|
75
|
-
import { AngularFirestoreModule } from '@angular/fire/compat/firestore';
|
|
76
|
-
import { environment } from '../environments/environment';
|
|
77
|
-
|
|
78
|
-
@NgModule({
|
|
79
|
-
imports: [
|
|
80
|
-
BrowserModule,
|
|
81
|
-
AngularFireModule.initializeApp(environment.firebase),
|
|
82
|
-
AngularFireAnalyticsModule,
|
|
83
|
-
AngularFirestoreModule
|
|
84
|
-
],
|
|
85
|
-
declarations: [ AppComponent ],
|
|
86
|
-
bootstrap: [ AppComponent ]
|
|
87
|
-
})
|
|
88
|
-
export class AppModule {}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### 7. Inject `AngularFirestore`
|
|
92
|
-
|
|
93
|
-
Open `/src/app/app.component.ts`, and make sure to modify/delete any tests to get the sample working (tests are still important, you know):
|
|
41
|
+
Open `/src/app/app.component.ts`, and make the following changes to :
|
|
94
42
|
|
|
95
43
|
```ts
|
|
96
|
-
import { Component } from '@angular/core';
|
|
97
|
-
import {
|
|
44
|
+
import { Component, inject } from '@angular/core';
|
|
45
|
+
import { Firestore } from '@angular/fire/firestore';
|
|
98
46
|
|
|
99
47
|
@Component({
|
|
100
48
|
selector: 'app-root',
|
|
@@ -102,19 +50,21 @@ import { AngularFirestore } from '@angular/fire/compat/firestore';
|
|
|
102
50
|
styleUrls: ['app.component.css']
|
|
103
51
|
})
|
|
104
52
|
export class AppComponent {
|
|
105
|
-
|
|
53
|
+
firestore: Firestore = inject(Firestore);
|
|
54
|
+
|
|
55
|
+
constructor() {
|
|
106
56
|
|
|
107
57
|
}
|
|
108
58
|
}
|
|
109
59
|
```
|
|
110
60
|
|
|
111
|
-
###
|
|
61
|
+
### 4. Bind a Firestore collection to a list
|
|
112
62
|
|
|
113
63
|
In `/src/app/app.component.ts`:
|
|
114
64
|
|
|
115
65
|
```ts
|
|
116
|
-
import { Component } from '@angular/core';
|
|
117
|
-
import {
|
|
66
|
+
import { Component, inject } from '@angular/core';
|
|
67
|
+
import { Firestore, collection, collectionData } from '@angular/fire/firestore';
|
|
118
68
|
import { Observable } from 'rxjs';
|
|
119
69
|
|
|
120
70
|
@Component({
|
|
@@ -123,9 +73,12 @@ import { Observable } from 'rxjs';
|
|
|
123
73
|
styleUrls: ['app.component.css']
|
|
124
74
|
})
|
|
125
75
|
export class AppComponent {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
76
|
+
firestore: Firestore = inject(Firestore)
|
|
77
|
+
items$: Observable<any[]>;
|
|
78
|
+
|
|
79
|
+
constructor() {
|
|
80
|
+
const aCollection = collection(this.firestore, 'items')
|
|
81
|
+
this.items$ = collectionData(aCollection);
|
|
129
82
|
}
|
|
130
83
|
}
|
|
131
84
|
```
|
|
@@ -134,25 +87,25 @@ Open `/src/app/app.component.html`:
|
|
|
134
87
|
|
|
135
88
|
```html
|
|
136
89
|
<ul>
|
|
137
|
-
<li class="text" *ngFor="let item of items | async">
|
|
90
|
+
<li class="text" *ngFor="let item of items$ | async">
|
|
138
91
|
{{item.name}}
|
|
139
92
|
</li>
|
|
140
93
|
</ul>
|
|
141
94
|
```
|
|
142
95
|
|
|
143
|
-
###
|
|
96
|
+
### 5. Run your app locally
|
|
144
97
|
|
|
145
98
|
```bash
|
|
146
99
|
ng serve
|
|
147
100
|
```
|
|
148
101
|
|
|
149
|
-
Your Angular app will compile and serve locally, visit it we should
|
|
102
|
+
Your Angular app will compile and serve locally, visit it we should find an empty list.
|
|
150
103
|
|
|
151
104
|
In another tab [start adding data to an `items` collection in Firestore](https://firebase.google.com/docs/firestore/manage-data/add-data). *As we're not authenticating users yet, be sure to start Firestore in **test mode** or allow reading from the `items` collection in Security Rules (`allow read: if true`).*
|
|
152
105
|
|
|
153
|
-
Once you've created a `items` collection and are inserting documents, you should
|
|
106
|
+
Once you've created a `items` collection and are inserting documents, you should find data streaming into your Angular application and being rendered in your browser.
|
|
154
107
|
|
|
155
|
-
###
|
|
108
|
+
### 6. Deploy your app
|
|
156
109
|
|
|
157
110
|
Finally, we can deploy the application to Firebase hosting:
|
|
158
111
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Firebase Tools Install and Setup
|
|
2
|
+
|
|
3
|
+
### 1. Install package
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g firebase-tools
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
or with `yarn`
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn global add firebase-tools
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
You can also choose to install it as a dependency for your project rather than globally
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev firebase-tools
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or with `yarn`
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add -D firebase-tools
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. Configure Firebase Tools
|
|
28
|
+
|
|
29
|
+
In your projects root directory run:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
firebase init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
or if your installed it within your project rather than globally
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx firebase init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
or with `yarn`
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn firebase init
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This will ask you to login if you are not logged in already, the process will take you through a browser
|
|
48
|
+
redirect to log you into Firebase.
|
|
49
|
+
|
|
50
|
+
### 3. Choose what Firebase features
|
|
51
|
+
|
|
52
|
+
`firebase-tools` displays Firebase features you want to configure.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
? Which Firebase features do you want to set up for this directory? Press Space
|
|
56
|
+
to select features, then Enter to confirm your choices. (Press <space> to select
|
|
57
|
+
, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
|
|
58
|
+
◯ Realtime Database: Configure a security rules file for Realtime Database and
|
|
59
|
+
(optionally) provision default instance
|
|
60
|
+
◯ Firestore: Configure security rules and indexes files for Firestore
|
|
61
|
+
◯ Functions: Configure a Cloud Functions directory and its files
|
|
62
|
+
◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub
|
|
63
|
+
Action deploys
|
|
64
|
+
◯ Hosting: Set up GitHub Action deploys
|
|
65
|
+
(Move up and down to reveal more choices)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 4. Connect your repo to a Firebase project
|
|
69
|
+
|
|
70
|
+
The CLI will then walk you through making sure your repo is configured with a Firebase project.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
? Please select an option:
|
|
74
|
+
◯ Use an existing project
|
|
75
|
+
◯ Create a new project
|
|
76
|
+
◯ Add Firebase to an existing Google Cloud Platform project
|
|
77
|
+
◯ Don't set up a default project
|
|
78
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/cloud-messaging-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Cloud Messaging
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Cloud Messaging
|
|
8
|
+
|
|
9
|
+
The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/cloud-messaging/)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
YADA YADA YADA
|
|
16
|
+
|
|
17
|
+
## Firebase API
|
|
18
|
+
|
|
19
|
+
Something something look at the offical docs
|
|
20
|
+
|
|
21
|
+
## Convenience observables
|
|
22
|
+
|
|
23
|
+
### Foo
|
|
24
|
+
|
|
25
|
+
bar baz
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/performance-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Performance Monitoring
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Performance Monitoring
|
|
8
|
+
|
|
9
|
+
Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your Apple, Android, and web apps.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/perf-mon)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
16
|
+
```bash
|
|
17
|
+
ng add @angular/fire
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide a Performance instance and configuration in the application's `NgModule` (`app.module.ts`):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
+
import { getPerformance, providePerformance} from '@angular/fire/performance';
|
|
25
|
+
|
|
26
|
+
@NgModule({
|
|
27
|
+
imports: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
29
|
+
providePerformance(() => getPerformance()),
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject it into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { Performance } from '@angular/fire/performance';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class PerformanceComponent {
|
|
42
|
+
private performance: Performance = inject(Performance);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
|
|
49
|
+
The [Performance documentation](https://firebase.google.com/docs/reference/js/performance.md#performance_package) is available on the Firebase website.
|
|
50
|
+
|
|
51
|
+
## Services
|
|
52
|
+
|
|
53
|
+
Coming soon.
|
|
54
|
+
|
|
55
|
+
## Convenience observables
|
|
56
|
+
|
|
57
|
+
Coming soon.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/remote-config-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime Remote Config
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Remote Config
|
|
8
|
+
|
|
9
|
+
Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/remote-config/)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
16
|
+
```bash
|
|
17
|
+
ng add @angular/fire
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide a Performance instance and configuration in the application's `NgModule` (`app.module.ts`):
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
24
|
+
import { getRemoteConfig, provideRemoteConfig} from '@angular/fire/remote-config';
|
|
25
|
+
|
|
26
|
+
@NgModule({
|
|
27
|
+
imports: [
|
|
28
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
29
|
+
provideRemoteConfig(() => getRemoteConfig()),
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Next inject it into your component:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject} from '@angular/core';
|
|
38
|
+
import { RemoteConfig } from '@angular/fire/remote-config';
|
|
39
|
+
|
|
40
|
+
@Component({ ... })
|
|
41
|
+
export class RemoteConfigComponent {
|
|
42
|
+
private remoteConfig: RemoteConfig = inject(RemoteConfig);
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Firebase API
|
|
48
|
+
|
|
49
|
+
The [Remote Config documentation](https://firebase.google.com/docs/reference/js/remote-config) is available on the Firebase website.
|
|
50
|
+
|
|
51
|
+
## Convenience observables
|
|
52
|
+
|
|
53
|
+
Coming soon.
|