Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
78
node_modules/rxfire/docs/auth.md
generated
vendored
Normal file
78
node_modules/rxfire/docs/auth.md
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
# RxFire Auth
|
||||
|
||||
## Auth State Observables
|
||||
|
||||
### `authState()`
|
||||
The `authState()` function creates an observable that emits authentication changes such as a logged out or logged in state.
|
||||
|
||||
| | |
|
||||
|-----------------|---------------------------------------------|
|
||||
| **function** | `authState()` |
|
||||
| **params** | `import('firebase/auth').Auth` |
|
||||
| **import path** | `rxfire/auth` |
|
||||
| **return** | `Observable<import('firebase/auth').User>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { authState } from 'rxfire/auth';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getAuth } from 'firebase/auth';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const auth = getAuth();
|
||||
authState(auth).subscribe(user => {
|
||||
console.log(user, ' will be null if logged out');
|
||||
});
|
||||
|
||||
// Listen only for logged in state
|
||||
const loggedIn$ = authState(auth).pipe(filter(user => !!user));
|
||||
loggedIn$.subscribe(user => { console.log(user); });
|
||||
```
|
||||
|
||||
### `user()`
|
||||
The `user()` function creates an observable that emits authentication changes such as a logged out, logged in, and token refresh state. The token refresh emissions is what makes `user()` different from `authState()`.
|
||||
|
||||
| | |
|
||||
|-----------------|---------------------------------------------|
|
||||
| **function** | `user()` |
|
||||
| **params** | `import('firebase/auth').Auth` |
|
||||
| **import path** | `rxfire/auth` |
|
||||
| **return** | `Observable<import('firebase/auth').User>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { user } from 'rxfire/auth';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getAuth } from 'firebase/auth';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const auth = getAuth();
|
||||
user(auth).subscribe(u => { console.log(u); );
|
||||
```
|
||||
|
||||
### `idToken()`
|
||||
The `idToken()` function creates an observable that emits the `idToken` refreshes. This is useful for keeping third party authentication in sync with Firebase Auth refreshes.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `idToken()` |
|
||||
| **params** | `import('firebase/auth').Auth` |
|
||||
| **import path** | `rxfire/auth` |
|
||||
| **return** | `Observable<string\|null>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { idToken } from 'rxfire/auth';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getAuth } from 'firebase/auth';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const auth = getAuth();
|
||||
idToken(auth).subscribe(token => { console.log(token); );
|
||||
```
|
248
node_modules/rxfire/docs/database.md
generated
vendored
Normal file
248
node_modules/rxfire/docs/database.md
generated
vendored
Normal file
|
@ -0,0 +1,248 @@
|
|||
# RxFire Database
|
||||
|
||||
## Object Observables
|
||||
|
||||
### `object()`
|
||||
The `object()` function creates an observable that emits object changes.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `object()` |
|
||||
| **params** | `import('firebase/database').Reference` |
|
||||
| **import path** | `rxfire/database` |
|
||||
| **return** | `Observable<QueryChange>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { object } from 'rxfire/database';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getDatabase } from 'firebase/database';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getDatabase(app);
|
||||
const ref = db.ref('users/david');
|
||||
|
||||
// Seed the database
|
||||
ref.set({ name: 'David' });
|
||||
|
||||
object(ref).subscribe(change => {
|
||||
const { event, snapshot, prevKey } = change;
|
||||
console.log(event, ' will always be value');
|
||||
console.log(prevKey, ' the previous key');
|
||||
console.log(snapshot.val(), ' this is the data');
|
||||
});
|
||||
|
||||
// Retrieve the data and key
|
||||
object(ref)
|
||||
.pipe(map(change => ({ _key: change.snapshot.key, ...change.snapshot.val() })))
|
||||
.subscribe(data => { console.log(data); });
|
||||
```
|
||||
|
||||
## List Observables
|
||||
|
||||
### `list()`
|
||||
The `list()` function creates an observable that emits a sorted array for each child event change. The optional `events` parameter will filter which child events populate the array.
|
||||
|
||||
| | |
|
||||
|-----------------|-------------------------------------------------------|
|
||||
| **function** | `list()` |
|
||||
| **params** | ref: `import('firebase/database').Reference` or `import('firebase/database').Query`, options?: { events?: `ListenEvent[]` } |
|
||||
| **import path** | `rxfire/database` |
|
||||
| **return** | `Observable<QueryChange[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { list, ListenEvent } from 'rxfire/database';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getDatabase } from 'firebase/database';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getDatabase(app);
|
||||
const ref = db.ref('users');
|
||||
|
||||
// Seed the database
|
||||
ref.push({ name: 'David' });
|
||||
|
||||
list(ref).subscribe(changes => {
|
||||
changes.forEach(change => {
|
||||
const { snapshot, event, prevKey } = change;
|
||||
console.log(event, ' the event that populated the array');
|
||||
console.log(prevKey, ' the previous key');
|
||||
console.log(snapshot.val(), ' this is the data of the single change');
|
||||
});
|
||||
});
|
||||
|
||||
// Retrieve the data, key, and event
|
||||
list(ref)
|
||||
.pipe(
|
||||
map(changes => changes.map(c => {
|
||||
return { _key: c.snapshot.key, event: c.event, ...c.snapshot.val() }
|
||||
})
|
||||
)
|
||||
.subscribe(users => { console.log(users); })
|
||||
|
||||
// Listen only to 'child_added' events
|
||||
list(ref, { events: [ListenEvent.added] } /* 'child_added' for js */)
|
||||
.subscribe(addedChanges => { console.log(addedChanges); });
|
||||
|
||||
// Listen only to 'child_added' and 'child_removed' events
|
||||
list(ref, { events: [ListenEvent.added, ListenEvent.removed] } /* 'child_added', 'child_removed' for js */)
|
||||
.subscribe(addedChanges => { console.log(addedChanges); });
|
||||
```
|
||||
|
||||
### `stateChanges()`
|
||||
The `stateChanges()` function creates an observable that emits each time a change occurs at the reference or query passed. This is useful for tracking the changes in your list. The optional `events` parameter will filter which child events populate the array.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------------------|
|
||||
| **function** | `stateChanges()` |
|
||||
| **params** | ref: `import('firebase/database').Reference` or `import('firebase/database').Query`, options:? { events?: `ListenEvent[]` } |
|
||||
| **import path** | `rxfire/database` |
|
||||
| **return** | `Observable<QueryChange>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { stateChanges, ListenEvent } from 'rxfire/database';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getDatabase } from 'firebase/database';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getDatabase(app);
|
||||
const ref = db.ref('users');
|
||||
|
||||
// Seed the database
|
||||
ref.push({ name: 'David' });
|
||||
|
||||
stateChanges(ref).subscribe(change => {
|
||||
const { event, snapshot, prevKey } = change;
|
||||
console.log(event, ' the event type that just occurred');
|
||||
console.log(snapshot.val(), ' the value of the change');
|
||||
});
|
||||
|
||||
// Retrieve the data, event, and key
|
||||
stateChanges(ref).pipe(
|
||||
map(change => {
|
||||
return {
|
||||
_key: change.snapshot.key,
|
||||
event: change.event,
|
||||
...change.snapshot.val();
|
||||
};
|
||||
})
|
||||
).subscribe(data => { console.log(data); });
|
||||
|
||||
// Listen only to 'child_added' events
|
||||
stateChanges(ref, { events: [ListenEvent.added] } /* 'child_added' for js */)
|
||||
.subscribe(addedChanges => { console.log(addedChanges); });
|
||||
|
||||
// Listen only to 'child_added' and 'child_removed' events
|
||||
stateChanges(ref, { events: [ListenEvent.added, ListenEvent.removed] } /* 'child_added', 'child_removed' for js */)
|
||||
.subscribe(addedChanges => { console.log(addedChanges); });
|
||||
|
||||
```
|
||||
|
||||
### `auditTrail()`
|
||||
The `auditTrail()` function creates an observable that emits the entire state trail. This is useful for debugging or replaying the state of a list in your app. The optional `events` parameter will filter which child events populate the array.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------------------|
|
||||
| **function** | `auditTrail()` |
|
||||
| **params** | ref: `import('firebase/database').Reference` or `import('firebase/database').Query`, options?: { events?: `ListenEvent[]` } |
|
||||
| **import path** | `rxfire/database` |
|
||||
| **return** | `Observable<QueryChange[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { auditTrail, ListenEvent } from 'rxfire/database';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getDatabase } from 'firebase/database';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getDatabase(app);
|
||||
const ref = db.ref('users');
|
||||
|
||||
// Seed the database
|
||||
const davidRef = ref.push();
|
||||
davidRef.set({ name: 'David' });
|
||||
|
||||
auditTrail(ref).pipe(
|
||||
map(change => {
|
||||
return {
|
||||
_key: change.snapshot.key,
|
||||
event: change.event,
|
||||
...change.snapshot.val();
|
||||
};
|
||||
})
|
||||
).subscribe(stateTrail => {
|
||||
console.log(stateTrail);
|
||||
/**
|
||||
first emission:
|
||||
[{ _key: '3qtWqaKga8jA; name: 'David', event: 'child_added' }]
|
||||
|
||||
second emission:
|
||||
[
|
||||
{ _key: '3qtWqaKga8jA; name: 'David', event: 'child_added' },
|
||||
{ _key: '3qtWqaKga8jA; name: 'David', event: 'child_removed' }
|
||||
]
|
||||
*/
|
||||
});
|
||||
|
||||
// When more events occur the trail still contains the previous events
|
||||
// In this case we'll remove the only item
|
||||
davidRef.remove();
|
||||
|
||||
// Now this will trigger the subscribe function above
|
||||
```
|
||||
|
||||
## Event Observables
|
||||
|
||||
The `fromRef()` function creates an observable that emits reference changes.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `fromRef()` |
|
||||
| **params** | ref: `import('firebase/database').Reference` or `import('firebase/database').Query`, event: `ListenEvent` |
|
||||
| **import path** | `rxfire/database` |
|
||||
| **return** | `Observable<QueryChange>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { fromRef, ListenEvent } from 'rxfire/database';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getDatabase } from 'firebase/database';
|
||||
import { merge } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getDatabase(app);
|
||||
const ref = db.ref('users');
|
||||
|
||||
// Seed the database
|
||||
ref.child('david').set({ name: 'David' });
|
||||
|
||||
// Subscribe to events
|
||||
fromRef(ref, ListenEvent.value /* 'value' for js users */)
|
||||
.subscribe(change => {
|
||||
// Get value changes, this is basically what `object()` does
|
||||
});
|
||||
|
||||
// Merge multiple events (however this is really what `stateChanges()` does)
|
||||
const addedChanges = fromRef(ref, ListenEvent.added);
|
||||
const removedChanges = fromRef(ref, ListenEvent.removed);
|
||||
merge(addedChanges, removedChanges)
|
||||
.subscribe(change => {
|
||||
const { event, snapshot, prevKey } = change;
|
||||
console.log(event); // This will be 'child_added' or 'child_removed'
|
||||
// Note: Don't write this yourself. Use `stateChanges()` for this type of
|
||||
// functionality. This is just an example of using fromRef for custom
|
||||
// behavior.
|
||||
});
|
||||
```
|
363
node_modules/rxfire/docs/firestore.md
generated
vendored
Normal file
363
node_modules/rxfire/docs/firestore.md
generated
vendored
Normal file
|
@ -0,0 +1,363 @@
|
|||
# RxFire Firestore
|
||||
|
||||
|
||||
### `doc()`
|
||||
The `doc()` function creates an observable that emits document changes. Returns snapshot of the data each time the document changes.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `doc()` |
|
||||
| **params** | `ref:import('firebase/firestore').DocumentReference` |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').DocumentSnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { doc } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, doc, setDoc } from 'firebase/firestore';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const davidDocRef = doc(db, 'users/david');
|
||||
|
||||
// Seed the firestore
|
||||
setDoc(davidDocRef, { name: 'David' });
|
||||
|
||||
doc(davidDocRef).subscribe(snapshot => {
|
||||
console.log(snapshot.id);
|
||||
console.log(snapshot.data());
|
||||
});
|
||||
```
|
||||
|
||||
### `docData()`
|
||||
The `docData()` function creates an observable that returns a stream of a document, mapped to its data field values and, optionally, the document ID.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `docData()` |
|
||||
| **params** | ref: `import('firebase/firestore').DocumentReference` <br> options?: { idField?: `string` } |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<T>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { docData } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, doc, setDoc } from 'firebase/firestore';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const davidDocRef = doc(db, 'users/david');
|
||||
|
||||
// Seed the firestore
|
||||
setDoc(davidDocRef, { name: 'David' });
|
||||
|
||||
docData(davidDocRef, { idField: 'uid' }).subscribe(userData => {
|
||||
console.log(`${userData.name} has id ${userData.uid}`);
|
||||
});
|
||||
```
|
||||
|
||||
## Collection Observables
|
||||
|
||||
### `collection()`
|
||||
The `collection()` function creates an observable that emits changes to the specified collection based on the input query. Any time updates are made, the function returns all documents in the collection that match the query.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `collection()` |
|
||||
| **params** | query: `import('firebase/firestore').CollectionReference \| import('firebase/firestore').Query` |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').QueryDocumentSnapshot[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { collection } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const collectionRef = collection(db, 'users');
|
||||
|
||||
collection(collectionRef)
|
||||
.pipe(map(docs => docs.map(d => d.data())))
|
||||
.subscribe(users => { console.log(users) });
|
||||
```
|
||||
|
||||
### `collectionData()`
|
||||
The `collectionData()` function creates an observable that emits a stream of documents for the specified collection based on the input query. When updates are made, returns all documents (field values and optional document ID) in the collection that match the query.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `collectionData()` |
|
||||
| **params** | query: `import('firebase/firestore').CollectionReference \| import('firebase/firestore').Query` <br> options?: { idField?: `string` } |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<T[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { collectionData } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const collectionRef = collection(db, 'users');
|
||||
|
||||
collectionData(collectionRef, { idField: 'uid' })
|
||||
.subscribe(users => { console.log(users) });
|
||||
```
|
||||
|
||||
### `collectionChanges()`
|
||||
The `collectionChanges()` function creates an observable that emits the changes on the specified collection based on the input query. This is different than the collection function in that it does not contain the state of your application but only the individual changes. The optional `events` parameter filters which the type of change populate the array. By default, all changes are emitted. Returns the affected documents and the type of change that occurred (added, modified, or removed).
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `collectionChanges()` |
|
||||
| **params** | query: `import('firebase/firestore').CollectionReference \| import('firebase/firestore').Query` <br> options?: { events?: `import('firebase/firestore').DocumentChangeType[]` } |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').DocumentChange[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { collectionChanges } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const collectionRef = collection(db, 'users');
|
||||
|
||||
// Listen to all events
|
||||
collectionChanges(collectionRef)
|
||||
.subscribe(changes => { console.log(changes) });
|
||||
|
||||
// Listen to only 'added' events
|
||||
collectionChanges(collectionRef, { events: ['added'] })
|
||||
.subscribe(addedEvents => { console.log(addedEvents) });
|
||||
```
|
||||
|
||||
### `sortedChanges()`
|
||||
The `sortedChanges()` function creates an observable that emits the reduced state of individual changes. This is different than the collection function in that it creates an array out of every individual change to occur. It also contains the `type` property to indicate what kind of change occurred. The optional `events` parameter will filter which child events populate the array.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `sortedChanges()` |
|
||||
| **params** | query: `import('firebase/firestore').CollectionReference \| import('firebase/firestore').Query` <br> options?: { events?: `import('firebase/firestore').DocumentChangeType[]` } |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').DocumentChange[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { sortedChanges } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const collectionRef = collection(db, 'users');
|
||||
|
||||
// Listen to all events
|
||||
sortedChanges(collectionRef)
|
||||
.subscribe(changes => { console.log(changes) });
|
||||
|
||||
// Listen to only 'added' events
|
||||
docChanges(collectionRef, { events: ['added'] })
|
||||
.subscribe(addedEvents => { console.log(addedEvents) });
|
||||
```
|
||||
|
||||
### `auditTrail()`
|
||||
The `auditTrail()` function creates an observable that emits the entire state trail on the specified collection based on the input query. This is useful for debugging or replaying the changes to the database. The optional `events` parameter filters which the type of change populate the array. By default, all changes are emitted.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------------------|
|
||||
| **function** | `auditTrail()` |
|
||||
| **params** | ref: `import('firebase/firestore').Reference \| import('firebase/firestore').Query` <br> options?: { events?: `import('firebase/firestore').DocumentChangeType[]` } |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').DocumentChange[]>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { auditTrail } from 'rxfire/firestore';
|
||||
import { firestore } from 'firebase';
|
||||
import { getFirestore, collection, doc, setDoc, deleteDoc } from 'firebase/firestore';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const collectionRef = collection(db, 'users');
|
||||
const davidDocRef = doc(collectionRef, 'david');
|
||||
|
||||
// Start the audit trail
|
||||
auditTrail(collectionRef).pipe(
|
||||
map(change => {
|
||||
return {
|
||||
_key: change.snapshot.key,
|
||||
event: change.event,
|
||||
...change.snapshot.val()
|
||||
};
|
||||
})
|
||||
).subscribe(stateTrail => {
|
||||
console.log(stateTrail);
|
||||
});
|
||||
|
||||
// Seed Firestore
|
||||
setDoc(davidDocRef, { name: 'David' });
|
||||
|
||||
// Remove the document
|
||||
deleteDoc(davidDocRef);
|
||||
|
||||
/**
|
||||
First emission:
|
||||
[{ _key: '3qtWqaKga8jA; name: 'David', event: 'added' }]
|
||||
|
||||
When more events occur, the trail still contains the previous events.
|
||||
|
||||
Second emission:
|
||||
[
|
||||
{ _key: '3qtWqaKga8jA; name: 'David', event: 'added' },
|
||||
{ _key: '3qtWqaKga8jA; name: 'David', event: 'removed' }
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
### `collectionCount()`
|
||||
|
||||
Create an observable that emits the server-calculated number of documents in a collection or query. [Learn more about count queries in the Firebase docs](https://firebase.google.com/docs/firestore/query-data/aggregation-queries).
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `collectionCount()` |
|
||||
| **params** | query: `import('firebase/firestore').CollectionReference \| import('firebase/firestore').Query`|
|
||||
| **import path** | `rxfire/firestore` or `rxfire/firestore/lite` |
|
||||
| **return** | `Observable<number>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { collectionCount } from 'rxfire/firestore';
|
||||
// Also available in firestore/lite
|
||||
import { collectionCount } from 'rxfire/firestore/lite';
|
||||
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
|
||||
const db = getFirestore();
|
||||
const likesCol = collection(db, 'posts/post_id_123/likes');
|
||||
|
||||
collectionCount(likesCol).subscribe(count => {
|
||||
console.log(count);
|
||||
});
|
||||
```
|
||||
|
||||
Note that the observable will complete after the first fetch. This is not a long-lived subscription. To update the count value over time, use the `repeat` operator:
|
||||
|
||||
```ts
|
||||
import { repeat } from 'rxjs';
|
||||
|
||||
import { collectionCount} from 'rxfire/firestore';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
|
||||
const db = getFirestore();
|
||||
const likesCol = collection(db, 'posts/post_id_123/likes');
|
||||
|
||||
collectionCount(likesCol)
|
||||
.pipe(
|
||||
// re-fetch every 30 seconds.
|
||||
// Stop fetching after 100 re-fetches so we don't do too many reads
|
||||
repeat({ count: 100, delay: 30 * 1000 }),
|
||||
)
|
||||
.subscribe((count) => {
|
||||
console.log(count);
|
||||
});
|
||||
```
|
||||
|
||||
### `collectionCountSnap()`
|
||||
|
||||
Create an observable that emits the server-calculated number of documents in a collection or query. [Learn more about count queries in the Firebase docs](https://firebase.google.com/docs/firestore/query-data/aggregation-queries).
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `collectionCountSnap()` |
|
||||
| **params** | query: `import('firebase/firestore').CollectionReference \| import('firebase/firestore').Query`|
|
||||
| **import path** | `rxfire/firestore` or `firebase/firestore/lite` |
|
||||
| **return** | `Observable<CountSnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { collectionCountSnap } from 'rxfire/firestore';
|
||||
// Also available in firestore/lite
|
||||
import { collectionCountSnap } from 'rxfire/firestore/lite';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
|
||||
const db = getFirestore();
|
||||
const likesCol = collection(db, 'posts/post_id_123/likes');
|
||||
|
||||
// One version with the snapshot
|
||||
countSnap$(likesCol).subscribe(snapshot => {
|
||||
console.log(snapshot.data().count);
|
||||
});
|
||||
```
|
||||
|
||||
## Event Observables
|
||||
|
||||
### `fromDocRef()`
|
||||
The `fromDocRef()` function creates an observable that emits document changes. This is an alias to the `doc()` function.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `fromDocRef()` |
|
||||
| **params** | ref: `import('firebase/firestore').DocumentReference` <br> options?: `import('firebase/firestore').SnapshotListenOptions` |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').DocumentSnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { fromDocRef } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, doc, setDoc } from 'firebase/firestore';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const davidDocRef = doc(db, 'users/david');
|
||||
|
||||
// Seed Firestore
|
||||
setDoc(davidDocRef, { name: 'David' });
|
||||
|
||||
fromDocRef(davidDocRef).subscribe(snap => { console.log(snap); })
|
||||
```
|
||||
|
||||
### `fromCollectionRef()`
|
||||
The `fromCollectionRef()` function creates an observable that emits changes to the specified collection based on the input query and, optionally, the listen options. This is different than the `collection()` function in that it returns the full `QuerySnapshot` representing the results of the query.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `fromCollectionRef()` |
|
||||
| **params** | ref: `import('firebase/firestore').Reference \| import('firebase/firestore').Query` <br> options?: `import('firebase/firestore').SnapshotListenOptions` |
|
||||
| **import path** | `rxfire/firestore` |
|
||||
| **return** | `Observable<import('firebase/firestore').QuerySnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { fromCollectionRef } from 'rxfire/firestore';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getFirestore, collection } from 'firebase/firestore';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const db = getFirestore(app);
|
||||
const collectionRef = collection(db, 'users');
|
||||
|
||||
fromCollectionRef(collectionRef).subscribe(snap => { console.log(snap.docs); })
|
||||
```
|
34
node_modules/rxfire/docs/functions.md
generated
vendored
Normal file
34
node_modules/rxfire/docs/functions.md
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
# RxFire Cloud Functions
|
||||
|
||||
## Callable Functions Observables
|
||||
|
||||
### `httpsCallable()`
|
||||
|
||||
The `httpsCallable()` function returns an observable that calls a [callable function](https://firebase.google.com/docs/functions/callable), then emits the data returned from that function.
|
||||
|
||||
| | |
|
||||
| --------------- | ------------------------------------------------------------------------ |
|
||||
| **function** | `httpsCallable()` |
|
||||
| **params** | `functions: Functions`, `name: string`, `options?: HttpsCallableOptions` |
|
||||
| **import path** | `rxfire/functions` |
|
||||
| **return** | `(data: T) => Observable<R>` |
|
||||
|
||||
#### TypeScript Example
|
||||
|
||||
```ts
|
||||
import { httpsCallable } from "rxfire/functions";
|
||||
import { initializeApp } from "firebase/app";
|
||||
import { getFunctions } from "firebase/functions";
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({
|
||||
/* config */
|
||||
});
|
||||
const functions = getFunctions(app);
|
||||
|
||||
// Assume an `uppercaser` function is deployed
|
||||
const capitalizedText$ = httpsCallable<string, string>(functions, "uppercaser")("hello world");
|
||||
capitalizedText$.subscribe((text) => {
|
||||
console.log(text);
|
||||
}); // logs "HELLO WORLD"
|
||||
```
|
174
node_modules/rxfire/docs/storage.md
generated
vendored
Normal file
174
node_modules/rxfire/docs/storage.md
generated
vendored
Normal file
|
@ -0,0 +1,174 @@
|
|||
# RxFire Storage
|
||||
|
||||
## Task Observables
|
||||
|
||||
### `fromTask()`
|
||||
The `fromTask()` function creates an observable that emits progress changes.
|
||||
|
||||
| | |
|
||||
|-----------------|--------------------------------------------|
|
||||
| **function** | `fromTask()` |
|
||||
| **params** | `import('firebase/storage').UploadTask` |
|
||||
| **import path** | `rxfire/storage` |
|
||||
| **return** | `Observable<firestore.UploadTaskSnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { fromTask } from 'rxfire/storage';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getStorage, ref, uploadString } from 'firebase/storage';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const storage = getStorage(app);
|
||||
const davidRef = ref(storage, 'users/david.png');
|
||||
|
||||
// Upload a transparent 1x1 pixel image
|
||||
const BASE_64_PIXEL = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
const task = uploadString(davidRef, BASE_64_PIXEL, 'base64');
|
||||
|
||||
fromTask(task)
|
||||
.subscribe(snap => { console.log(snap.bytesTransferred); });
|
||||
```
|
||||
|
||||
### `percentage()`
|
||||
The `percentage()` function creates an observable that emits percentage of the uploaded bytes.
|
||||
|
||||
| | |
|
||||
|-----------------|--------------------------------------------|
|
||||
| **function** | `percentage()` |
|
||||
| **params** | `import('firebase/storage').UploadTask` |
|
||||
| **import path** | `rxfire/storage` |
|
||||
| **return** | `Observable<number>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { percentage } from 'rxfire/storage';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getStorage, ref, uploadString } from 'firebase/storage';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const storage = getStorage(app);
|
||||
const davidRef = ref(storage, 'users/david.png');
|
||||
|
||||
// Upload a transparent 1x1 pixel image
|
||||
const BASE_64_PIXEL = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
const task = uploadString(davidRef, BASE_64_PIXEL, 'base64');
|
||||
|
||||
percentage(task)
|
||||
.subscribe(action => { console.log(action.progress, action.snapshot); });
|
||||
```
|
||||
|
||||
## Reference Observables
|
||||
|
||||
### `getDownloadURL()`
|
||||
The `getDownloadURL()` function creates an observable that emits the URL of the file.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `getDownloadURL()` |
|
||||
| **params** | `import('firebase/storage').StorageReference` |
|
||||
| **import path** | `rxfire/storage` |
|
||||
| **return** | `Observable<string>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { getDownloadURL } from 'rxfire/storage';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getStorage, ref } from 'firebase/storage';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const storage = getStorage(app);
|
||||
|
||||
// Assume this exists
|
||||
const davidRef = ref(storage, 'users/david.png');
|
||||
|
||||
getDownloadURL(davidRef)
|
||||
.subscribe(url => { console.log(url) });
|
||||
```
|
||||
|
||||
### `getMetadata()`
|
||||
The `getMetadata()` function creates an observable that emits the URL of the file's metadta.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `getMetadata()` |
|
||||
| **params** | `import('firebase/storage').StorageReference` |
|
||||
| **import path** | `rxfire/storage` |
|
||||
| **return** | `Observable<Object>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { getMetadata } from 'rxfire/storage';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getStorage, ref } from 'firebase/storage';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const storage = getStorage(app);
|
||||
|
||||
// Assume this exists
|
||||
const davidRef = ref(storage, 'users/david.png');
|
||||
|
||||
getMetadata(davidRef)
|
||||
.subscribe(meta => { console.log(meta) });
|
||||
```
|
||||
|
||||
### `uploadBytesResumable()`
|
||||
The `uploadBytesResumable()` function creates an observable that emits the upload progress of a file. **Breaking change**: Renamed from `put()` in previous API.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `uploadBytesResumable()` |
|
||||
| **params** | ref: `import('firebase/storage').StorageReference`, data: `any`, metadata?: `import('firebase/storage').UploadMetadata` |
|
||||
| **import path** | `rxfire/storage` |
|
||||
| **return** | `Observable<import('firebase/storage').UploadTaskSnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { uploadBytesResumable } from 'rxfire/storage';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getStorage, ref } from 'firebase/storage';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const storage = getStorage(app);
|
||||
const davidRef = ref(storage, 'users/david.json');
|
||||
|
||||
const blob = new Blob(
|
||||
[JSON.stringify({ name: 'david'}, null, 2)],
|
||||
{ type : 'application/json' }
|
||||
);
|
||||
|
||||
uploadBytesResumable(davidRef, blob, { type : 'application/json' })
|
||||
.subscribe(snap => { console.log(snap.bytesTransferred) });
|
||||
```
|
||||
|
||||
### `uploadString()`
|
||||
The `uploadString()` function creates an observable that emits the upload progress of a file. **Breaking change**: Renamed from `putString()` in previous API.
|
||||
|
||||
| | |
|
||||
|-----------------|------------------------------------------|
|
||||
| **function** | `uploadString()` |
|
||||
| **params** | ref: `import('firebase/storage').StorageReference`, data: `string`, metadata?: `import('firebase/storage').UploadMetadata` |
|
||||
| **import path** | `rxfire/storage` |
|
||||
| **return** | `Observable<import('firebase/storage').UploadTaskSnapshot>` |
|
||||
|
||||
#### TypeScript Example
|
||||
```ts
|
||||
import { uploadString } from 'rxfire/storage';
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getStorage, ref } from 'firebase/storage';
|
||||
|
||||
// Set up Firebase
|
||||
const app = initializeApp({ /* config */ });
|
||||
const storage = getStorage(app);
|
||||
const davidRef = ref('users/david.png');
|
||||
|
||||
const base64 = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
|
||||
uploadString(davidRef, base64, { type : 'application/json' })
|
||||
.subscribe(snap => { console.log(snap.bytesTransferred) });
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue