Skip to content

Commit da5197c

Browse files
shelcindrajamesdaniels
authored andcommitted
Added docData function to documentation. (#2571)
1 parent d4ddeaf commit da5197c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/rxfire/docs/firestore.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@ doc(davidDoc).subscribe(snapshot => {
3333
});
3434
```
3535

36+
### `docData()`
37+
The `docData()` function returns a stream of a document, mapped to its data payload and optionally the document ID.
38+
39+
| | |
40+
|-----------------|------------------------------------------|
41+
| **function** | `docData()` |
42+
| **params** | ref: `firestore.DocumentReference` <br> idField?: `string` |
43+
| **import path** | `rxfire/firestore` |
44+
| **return** | `Observable<T>` |
45+
46+
#### TypeScript Example
47+
```ts
48+
import { docData } from 'rxfire/firestore';
49+
import { firestore, initializeApp } from 'firebase';
50+
import 'firebase/firestore';
51+
52+
// Set up Firebase
53+
const app = initializeApp({ /* config */ });
54+
const db = app.firestore();
55+
const davidDocRef = db.doc('users/david');
56+
57+
// Seed the firestore
58+
davidDocRef.set({ name: 'David' });
59+
60+
docData(davidDocRef,'uid').subscribe(userData => {
61+
console.log(`${userData.name} has id ${userData.uid}`);
62+
});
63+
```
64+
3665
## Collection Observables
3766

3867
### `collection()`

0 commit comments

Comments
 (0)