Skip to content

Commit 52247a6

Browse files
committed
Doc changes
1 parent 674ff68 commit 52247a6

File tree

5 files changed

+67
-46
lines changed

5 files changed

+67
-46
lines changed

docs/version-7-upgrade.md

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Intended to be run with Angular 12, AngularFire 7.0 allows you to take full advtange of the new tree-shakable Firebase JS SDK (v9) while also providing a compatible expirience with the prior API.
44

5+
`ng update @angular/fire --next`
6+
57
## Compatibility mode
68

79
AngularFire v7.0 has a compatibility layer that supports the AngularFire v6.0 API. Just change your imports from `@angular/fire/*` to `@angular/fire/compat/*` and `firebase/*` to `firebase/compat/*`.
@@ -19,11 +21,10 @@ In order to better support the tree-shakability introduced in Firebase v9 & to r
1921
@NgModule({
2022
imports: [
2123
AngularFire.initalizeApp(config),
22-
AngularFirestoreModule.enablePersistence({ synchronizeTabs: true }),
24+
AngularFirestoreModule.enablePersistence(),
2325
AngularFireStorageModule,
2426
],
2527
providers: [
26-
{ provide: SETTINGS, useValue: { ignoreUndefinedProperties: true } },
2728
{ provide: USE_EMULATOR, useValue: ['localhost', 8080] },
2829
],
2930
})
@@ -42,9 +43,6 @@ In order to better support the tree-shakability introduced in Firebase v9 & to r
4243
}),
4344
provideStorage(() => getStorage()),
4445
],
45-
providers: [
46-
{ provide: FIRESTORE_SETTINGS, useValue: { ignoreUndefinedProperties: true } },
47-
],
4846
})
4947
```
5048

@@ -54,17 +52,16 @@ Before when you injected Firebase JS SDK services into AngularFire they would be
5452

5553
```ts
5654
import { FirebaseApp } from '@angular/fire';
57-
import { Firestore } from '@angular/fire/firestore';
58-
import { doc, onSnapshot } from 'firebase/firestore';
55+
import { Firestore, doc, onSnapshot } from '@angular/fire/firestore';
5956

6057
@Component({})
6158
export class Foo {
6259
constructor(
6360
app: FirebaseApp,
6461
firestore: Firestore, // Injects the instantiated Firestore instance
6562
) {
66-
// You can directly operate on the instance with the JS SDK
67-
// NOTE: you will have to handle change-detection yourself
63+
// You can directly operate on the instance with the JS SDK or use our "reexported"
64+
// API calls for Zone.js wrapping
6865
onSnapshot(doc(firestore, 'foo/1'), snap => {
6966
// ...
7067
});
@@ -80,79 +77,103 @@ AngularFire no longer provides observables and functions as class methods, evert
8077
<thead>
8178
<tr>
8279
<th colspan="2">v6 / Compat</th>
83-
<th >v7 Modular</th>
80+
<th>v7 Modular</th>
8481
</tr>
8582
</thead>
8683
<tbody>
8784
<tr>
8885
<th rowspan="3">AngularFirestore</th>
8986
<td>doc</td>
90-
<td rowspan="3">
91-
<p><small>Since we no longer inject our own class (and to better support tree-shaking) use the JS SDK methods to get docs/collections.</small></p>
87+
<td>
9288

9389
```ts
94-
import {
95-
doc,
96-
collection,
97-
collectionGroup,
98-
} from 'firebase/firestore'
90+
import { doc } from '@angular/fire/firestore'
9991
```
100-
10192
</td>
10293
</tr>
10394
<tr>
10495
<td>collection</td>
96+
<td>
97+
98+
```ts
99+
import { collection } from '@angular/fire/firestore'
100+
```
101+
</td>
105102
</tr>
106103
<tr>
107104
<td>collectionGroup</td>
105+
<td>
106+
107+
```ts
108+
import { collectionGroup } from '@angular/fire/firestore'
109+
```
110+
</td>
108111
</tr>
109112
<tr>
110113
<th rowspan="7">AngularFirestoreDocument</th>
111114
<td>set</td>
112-
<td rowspan="4">
115+
<td>
113116

114117
```ts
115-
import {
116-
setDoc,
117-
updateDoc,
118-
deleteDoc,
119-
collection,
120-
} from 'firebase/firestore'
118+
import { setDoc } from '@angular/fire/firestore'
121119
```
120+
</td>
122121

123122
</td>
124123
</tr>
125124
<tr>
126125
<td>update</td>
126+
<td>
127+
128+
```ts
129+
import { updateDoc } from '@angular/fire/firestore'
130+
```
131+
</td>
127132
</tr>
128133
<tr>
129134
<td>delete</td>
135+
<td>
136+
137+
```ts
138+
import { deleteDoc } from '@angular/fire/firestore'
139+
```
140+
</td>
130141
</tr>
131142
<tr>
132143
<td>collection</td>
144+
<td>
145+
146+
```ts
147+
import { collection } from '@angular/fire/firestore'
148+
```
149+
</td>
133150
</tr>
134151
<tr>
135152
<td>snapshotChanges</td>
136-
<td rowspan="2">
153+
<td>
137154

138155
```ts
139-
import {
140-
snapshotChanges,
141-
valueChanges,
142-
} from '@angular/fire/firestore'
156+
import { docSnapshots } from '@angular/fire/firestore'
143157
```
158+
</td>
144159

145160
</td>
146161
</tr>
147162
<tr>
148163
<td>valueChanges</td>
164+
<td>
165+
166+
```ts
167+
import { docData } from '@angular/fire/firestore'
168+
```
169+
</td>
149170
</tr>
150171
<tr>
151172
<td>get</td>
152173
<td>
153174

154175
```ts
155-
import { doc } from '@angular/fire/firestore'
176+
import { get } from '@angular/fire/firestore'
156177
```
157178

158179
</td>
@@ -233,8 +254,12 @@ AngularFire does not lazy-load services any longer. We have provided a helper ob
233254

234255
```ts
235256
// firestore_operations.ts
236-
import { collection, getFirestore } from 'firebase/firestore';
237-
import { collectionData, firestoreInstance$ } from '@angular/fire/firestore';
257+
import {
258+
collectionData,
259+
firestoreInstance$,
260+
collection,
261+
getFirestore
262+
} from '@angular/fire/firestore';
238263
import { first } from 'rxjs/operators';
239264

240265
export { getFirestore };
@@ -285,9 +310,6 @@ In AngularFire v7 working with multiple instances was difficult, in the new SDK
285310
provideStorage(() => getStorage(getApp(), 'another bucket')),
286311
provideStorage(() => getStorage(getApp('anotherApp'))),
287312
],
288-
providers: [
289-
{ provide: FIRESTORE_SETTINGS, useValue: { ignoreUndefinedProperties: true } },
290-
],
291313
})
292314
```
293315

sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@angular/common": "^12.0.0",
1818
"@angular/compiler": "^12.0.0",
1919
"@angular/core": "^12.0.0",
20-
"@angular/fire": "7.0.0-canary.d3a9af2",
20+
"@angular/fire": "7.0.0-alpha.3",
2121
"@angular/forms": "^12.0.0",
2222
"@angular/platform-browser": "^12.0.0",
2323
"@angular/platform-browser-dynamic": "^12.0.0",

sample/src/app/app.module.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3-
import { provideFirebaseApp } from '@angular/fire/app';
4-
import { provideAuth } from '@angular/fire/auth';
5-
import { initializeApp, getApp } from 'firebase/app';
6-
import { initializeAuth } from 'firebase/auth';
3+
import { provideFirebaseApp, getApp } from '@angular/fire/app';
4+
import { provideAuth, initializeAuth } from '@angular/fire/auth';
5+
import { initializeApp } from 'firebase/app';
76
import { AppRoutingModule } from './app-routing.module';
87
import { AppComponent } from './app.component';
98
import { environment } from '../environments/environment';

sample/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@
216216
dependencies:
217217
tslib "^2.2.0"
218218

219-
"@angular/[email protected]canary.d3a9af2":
220-
version "7.0.0-canary.d3a9af2"
221-
resolved "https://registry.yarnpkg.com/@angular/fire/-/fire-7.0.0-canary.d3a9af2.tgz#28050f12da5e9310d209ca0a4e2bc3e0a20ab0d4"
222-
integrity sha512-Jrnen55L0xuhGLEGlbtB7kbzN1ZKE/LQN0aASAxlZ/FnD1CRDmlZlYr4Clz1/ZJH6yMu7sMw72NlI7vk/dJoBA==
219+
"@angular/[email protected]alpha.3":
220+
version "7.0.0-alpha.3"
221+
resolved "https://registry.yarnpkg.com/@angular/fire/-/fire-7.0.0-alpha.3.tgz#d3b7c2414ffbc2ffbda6bb7c4f2bdf0779a40ce2"
222+
integrity sha512-5S8olqo33OGNOn9/3fKQixHQBFUjNU3FelkC0ScBbMCjHC/nYoUukYLBWDhu/MwNX2RnfujFuMGUb41NPN9OFw==
223223
dependencies:
224224
tslib "^2.0.0"
225225

src/schematics/update/v7/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const ngUpdate = (): Rule => (
4545
if (!content) {
4646
return;
4747
}
48-
// TODO clean this up
48+
// TODO clean this up, skip overwrite if uneeded
4949
content.replace(/(?<key>import|export)\s+(?:(?<alias>[\w,{}\s\*]+)\s+from)?\s*(?:(["'])?firebase\/(?<ref>[@\w\s\\\/.-]+)\3?)\s*;/, '$1 $2 from $3firebase/compat/$4$3;');
5050
content.replace(/(?<key>import|export)\s+(?:(?<alias>[\w,{}\s\*]+)\s+from)?\s*(?:(["'])?@firebase\/(?<ref>[@\w\s\\\/.-]+)\3?)\s*;/, '$1 $2 from $3@firebase/compat/$4$3;');
5151
content.replace(/(?<key>import|export)\s+(?:(?<alias>[\w,{}\s\*]+)\s+from)?\s*(?:(["'])?@angular\/fire\/(?<ref>[@\w\s\\\/.-]+)\3?)\s*;/, '$1 $2 from $3@angular/fire/compat/$4$3;');

0 commit comments

Comments
 (0)