@@ -10,7 +10,7 @@ The `AngularFirestoreCollection` service is a wrapper around the native Firestor
10
10
``` ts
11
11
import { Component } from ' @angular/core' ;
12
12
import { AngularFirestore , AngularFirestoreCollection } from ' angularfire2/firestore' ;
13
- import { Observable } from ' rxjs/Observable ' ;
13
+ import { Observable } from ' rxjs' ;
14
14
15
15
export interface Item { name: string ; }
16
16
@@ -86,7 +86,7 @@ There are multiple ways of streaming collection data from Firestore.
86
86
``` ts
87
87
import { Component } from ' @angular/core' ;
88
88
import { AngularFirestore , AngularFirestoreCollection } from ' angularfire2/firestore' ;
89
- import { Observable } from ' rxjs/Observable ' ;
89
+ import { Observable } from ' rxjs' ;
90
90
91
91
export interface Item { id: string ; name: string ; }
92
92
@@ -135,8 +135,8 @@ export class AppComponent {
135
135
``` ts
136
136
import { Component } from ' @angular/core' ;
137
137
import { AngularFirestore , AngularFirestoreCollection } from ' angularfire2/firestore' ;
138
- import { Observable } from ' rxjs/Observable ' ;
139
- import ' rxjs/add/operator/map ' ;
138
+ import { Observable } from ' rxjs' ;
139
+ import { map } from ' rxjs/operators ' ;
140
140
141
141
export interface Shirt { name: string ; price: number ; }
142
142
export interface ShirtId extends Shirt { id: string ; }
@@ -159,13 +159,13 @@ export class AppComponent {
159
159
// .snapshotChanges() returns a DocumentChangeAction[], which contains
160
160
// a lot of information about "what happened" with each change. If you want to
161
161
// get the data and the id use the map operator.
162
- this .shirts = this .shirtCollection .snapshotChanges ().map ( actions => {
163
- return actions .map (a => {
162
+ this .shirts = this .shirtCollection .snapshotChanges ().pipe (
163
+ map ( actions => actions .map (a => {
164
164
const data = a .payload .doc .data () as Shirt ;
165
165
const id = a .payload .doc .id ;
166
166
return { id , ... data };
167
- });
168
- } );
167
+ }))
168
+ );
169
169
}
170
170
}
171
171
```
@@ -181,7 +181,8 @@ export class AppComponent {
181
181
``` ts
182
182
import { Component } from ' @angular/core' ;
183
183
import { AngularFirestore , AngularFirestoreCollection } from ' angularfire2/firestore' ;
184
- import { Observable } from ' rxjs/Observable' ;
184
+ import { Observable } from ' rxjs' ;
185
+ import { map } from ' rxjs/operators' ;
185
186
186
187
export interface AccountDeposit { description: string ; amount: number ; }
187
188
export interface AccountDepoistId extends AccountDeposit { id: string ; }
@@ -201,14 +202,13 @@ export class AppComponent {
201
202
deposits: Observable <AccountDepositId []>;
202
203
constructor (private readonly afs : AngularFirestore ) {
203
204
this .depositCollection = afs .collection <AccountDeposit >(' deposits' );
204
- this .deposits = this .depositCollection .stateChanges ([' added' ])
205
- .map (actions => {
206
- return actions .map (a => {
207
- const data = a .payload .doc .data () as AccountDeposit ;
208
- const id = a .payload .doc .id ;
209
- return { id , ... data };
210
- })
211
- });
205
+ this .deposits = this .depositCollection .stateChanges ([' added' ]).pipe (
206
+ map (actions => actions .map (a => {
207
+ const data = a .payload .doc .data () as AccountDeposit ;
208
+ const id = a .payload .doc .id ;
209
+ return { id , ... data };
210
+ }))
211
+ );
212
212
}
213
213
}
214
214
```
@@ -224,7 +224,8 @@ export class AppComponent {
224
224
``` ts
225
225
import { Component } from ' @angular/core' ;
226
226
import { AngularFirestore , AngularFirestoreCollection } from ' angularfire2/firestore' ;
227
- import { Observable } from ' rxjs/Observable' ;
227
+ import { Observable } from ' rxjs' ;
228
+ import { map } from ' rxjs/operators' ;
228
229
229
230
export interface AccountLogItem { description: string ; amount: number ; }
230
231
export interface AccountLogItemId extends AccountLogItem { id: string ; }
@@ -244,14 +245,13 @@ export class AppComponent {
244
245
accountLogs: Observable <AccountLogItemId []>;
245
246
constructor (private readonly afs : AngularFirestore ) {
246
247
this .accountLogCollection = afs .collection <AccountLogItem >(' accountLog' );
247
- this .accountLogs = this .accountLogCollection .auditTrail ()
248
- .map (actions => {
249
- return actions .map (a => {
250
- const data = a .payload .doc .data () as AccountLogItem ;
251
- const id = a .payload .doc .id ;
252
- return { id , ... data };
253
- })
254
- });
248
+ this .accountLogs = this .accountLogCollection .auditTrail ().pipe (
249
+ map (actions => actions .map (a => {
250
+ const data = a .payload .doc .data () as AccountLogItem ;
251
+ const id = a .payload .doc .id ;
252
+ return { id , ... data };
253
+ }))
254
+ );
255
255
}
256
256
}
257
257
```
@@ -272,7 +272,7 @@ There are three `DocumentChangeType`s in Firestore: `added`, `removed`, and `mod
272
272
``` ts
273
273
import { Component } from ' @angular/core' ;
274
274
import { AngularFirestore , AngularFirestoreCollection } from ' angularfire2/firestore' ;
275
- import { Observable } from ' rxjs/Observable ' ;
275
+ import { Observable } from ' rxjs' ;
276
276
277
277
@Component ({
278
278
selector: ' app-root' ,
0 commit comments