6.0.5 • Published 7 months ago

rxfire v6.0.5

Weekly downloads
24,143
License
Apache-2.0
Repository
github
Last release
7 months ago

RxFire

Firebase and RxJS for all frameworks.

What is RxFire?

  • Observable creators - Observables bindings for most Firebase web libraries.
  • Portable - Use across any framework or no framework at all.
  • Tree shake-able - Import only what you need. Shake the rest out with your favorite module bundler like Webpack or Rollup.
  • Combine multiple data sources - Need to join two Firestore references? Want to combine an image from Cloud Storage with a Firestore document? Super easy with observables and operators.
  • Simplify code-splitting of Firebase - Using RxFire with Webpack makes it easy to load Firebase features on-demand.

Status: Beta

Install

# npm
npm i rxfire firebase rxjs --save
# yarn
yarn add rxfire firebase rxjs

Make sure to install Firebase and RxJS individually as they are peer dependencies of RxFire.

Example use:

import { initializeApp } from 'firebase/app';
import { getFirestore, collection, where, query } from 'firebase/firestore';
import { collectionData } from 'rxfire/firestore';
import { tap } from 'rxjs/operators';

const app = initializeApp({ /* config */ });
const firestore = getFirestore(app);
const citiesRef = query(
    collection(firestore, 'cities'),
    where('state', '==', 'CO')
);

collectionData(citiesRef, { idField: 'id' })
  .pipe(
    tap(cities => console.log('This is just an observable!'))
  )
  .subscribe(cities => { /* update UI */ })

Easily combine multiple Firebase data sources

RxJS provides multiple operators and creation methods for combining observable streams. This makes it easy to combine data from multiple Firebase resources. You can also handle simplify high asynchronous tasks like joins into a flat stream.

The example below streams a list of "cities" from Firestore and then retrieves their image from a Cloud Storage bucket. Both tasks are asynchronous but RxJS makes it easy to combine these tasks together.

import { initializeApp } from 'firebase/app';
import { getStorage, ref } from 'firebase/storage';
import { getFirestore, collection, where, query } from 'firebase/firestore';
import { collectionData } from 'rxfire/firestore';
import { getDownloadURL } from 'rxfire/storage';
import { combineLatest } from 'rxjs';
import { switchMap } from 'rxjs/operators';

const app = initializeApp({ /* config */ });
const firestore = getFirestore(app);
const storage = getStorage(app);
const citiesRef = query(
    collection(firestore, 'cities'),
    where('state', '==', 'CO')
);

collectionData(citiesRef, { idField: 'id' })
  .pipe(
    switchMap(cities => {
      return combineLatest(...cities.map(c => {
        const ref = ref(storage, `/cities/${c.id}.png`);
        return getDownloadURL(ref).pipe(map(imageURL => ({ imageURL, ...c })));
      }));
    })
  )
  .subscribe(cities => {
    cities.forEach(c => console.log(c.imageURL));
  });

Understanding RxFire imports

RxFire is a complementary library to Firebase. It is not meant to wrap the entire Firebase SDK. RxFire's purpose is to simplify async streams from Firebase. You need to import the Firebase SDK and initialize an app before using RxFire.

import { initializeApp } from 'firebase/app';
import { getStorage, ref } from 'firebase/storage';
import { getDownloadURL } from 'rxfire/storage';

const app = initializeApp({ /* config */ });
const storage = getStorage(app);
const ref = ref(storage, 'data.json');

// Now you can use RxFire!
const url$ = getDownloadURL(ref);

RxFire contains multiple entry points for module imports. Each Firebase library is an entry point.

import { } from 'rxfire/firestore';
import { } from 'rxfire/database';
import { } from 'rxfire/storage';
import { } from 'rxfire/auth';
import { } from 'rxfire/functions';
import { } from 'rxfire/performance';
import { } from 'rxfire/remote-config';

Simple functions

RxFire is a set of functions. Most functions create observables and from there you can use regular RxJS operators. Some functions are custom operators. But at the end of the day, it's all just functions. This is important for tree shaking. Any unused functions are stripped from your final build if you use a module bundler like Webpack or Rollup.

import { initializeApp } from 'firebase/app';
import { getStorage, ref } from 'firebase/storage';
import { getDownloadURL, put /* not used! */ } 'rxfire/storage';

const app = initializeApp({ /* config */ });
const storage = getStorage(app);
const ref = ref(storage, 'data.json');

const url$ = getDownloadURL(ref);

Documentation

Examples

Examples: See this example repository for a list of ways to configure and use RxFire.

6.0.5

7 months ago

6.0.4

7 months ago

6.0.3

2 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

6.0.0-rc.2

3 years ago

5.0.0-rc.4

3 years ago

6.0.0-rc.1

3 years ago

6.0.0-rc.0

3 years ago

5.0.0-rc.3

3 years ago

5.0.0-rc.2

3 years ago

5.0.0-rc.1

3 years ago

5.0.0-rc.0

3 years ago

4.0.0

3 years ago

3.13.5

4 years ago

3.13.5-0

4 years ago

3.13.4

4 years ago

3.13.4-0

4 years ago

3.13.3

4 years ago

3.13.2

4 years ago

3.13.3-0

4 years ago

3.13.2-0

4 years ago

3.13.1

4 years ago

3.13.1-0

4 years ago

3.13.0

4 years ago

3.13.0-0

4 years ago

3.12.6

4 years ago

3.12.6-0

4 years ago

3.12.5

4 years ago

3.12.5-0

4 years ago

3.12.4

4 years ago

3.12.4-0

4 years ago

3.12.3

4 years ago

3.12.3-0

4 years ago

3.12.2

4 years ago

3.12.2-0

4 years ago

3.12.1

4 years ago

3.12.1-0

4 years ago

3.12.0-0

4 years ago

3.12.0

4 years ago

3.11.2

4 years ago

3.11.2-0

4 years ago

3.11.1

4 years ago

3.11.1-0

4 years ago

3.11.0

4 years ago

3.11.0-1

4 years ago

3.11.0-0

4 years ago

3.10.1

4 years ago

3.10.1-0

4 years ago

3.10.0-2

4 years ago

3.10.0

4 years ago

3.10.0-1

4 years ago

3.10.0-0

4 years ago

3.9.16

4 years ago

3.9.16-0

4 years ago

3.9.15

4 years ago

3.9.15-0

4 years ago

3.9.14

4 years ago

3.9.14-2

4 years ago

3.9.14-1

4 years ago

3.9.14-0

4 years ago

3.9.13

4 years ago

3.9.13-0

4 years ago

3.9.12

4 years ago

3.9.12-0

4 years ago

3.9.11

4 years ago

3.9.11-0

4 years ago

3.9.10

4 years ago

3.9.10-0

4 years ago

3.9.9

4 years ago

3.9.9-1

4 years ago

3.9.9-0

4 years ago

3.9.8

4 years ago

3.9.8-0

4 years ago

3.9.7

4 years ago

3.9.7-0

4 years ago

3.9.6

4 years ago

3.9.6-0

4 years ago

3.9.5

4 years ago

3.9.5-1

4 years ago

3.9.5-0

4 years ago

3.9.4

4 years ago

3.9.4-0

4 years ago

3.9.3

4 years ago

3.9.3-1

4 years ago

3.9.3-0

4 years ago

3.9.2

4 years ago

3.9.2-0

4 years ago

3.9.1

4 years ago

3.9.1-0

4 years ago

3.9.0

4 years ago

3.9.0-0

4 years ago

3.8.8

4 years ago

3.8.8-1

4 years ago

3.8.8-0

4 years ago

3.8.7

4 years ago

3.8.7-1

4 years ago

3.8.7-0

4 years ago

3.8.6

4 years ago

3.8.6-0

4 years ago

3.8.5

4 years ago

3.8.5-0

4 years ago

3.8.4

4 years ago

3.8.4-0

4 years ago

3.8.3

5 years ago

3.8.3-0

5 years ago

3.8.2

5 years ago

3.8.2-1

5 years ago

3.8.2-0

5 years ago

3.8.1

5 years ago

3.8.1-0

5 years ago

3.8.0

5 years ago

3.8.0-1

5 years ago

3.8.0-0

5 years ago

3.7.1

5 years ago

3.7.1-0

5 years ago

3.7.0

5 years ago

3.7.0-0

5 years ago

3.6.12

5 years ago

3.6.12-0

5 years ago

3.6.11

5 years ago

3.6.11-0

5 years ago

3.6.10

5 years ago

3.6.10-0

5 years ago

3.6.9

5 years ago

3.6.9-0

5 years ago

3.6.8

5 years ago

3.6.8-0

5 years ago

3.6.7

5 years ago

3.6.7-0

5 years ago

3.6.6

5 years ago

3.6.6-0

5 years ago

3.6.5

5 years ago

3.6.5-1

5 years ago

3.6.5-0

5 years ago

3.6.4

5 years ago

3.6.4-0

5 years ago

3.6.3

5 years ago

3.6.3-1

5 years ago

3.6.3-0

5 years ago

3.6.2

5 years ago

3.6.2-0

5 years ago

3.6.1

5 years ago

3.6.1-0

5 years ago

3.6.0

5 years ago

3.6.0-0

5 years ago

3.5.1

5 years ago

3.5.1-0

5 years ago

3.5.0

5 years ago

3.5.0-0

5 years ago

3.4.8

5 years ago

3.4.8-0

5 years ago

3.4.7

5 years ago

3.4.7-0

5 years ago

3.4.6

5 years ago

3.4.6-0

5 years ago

3.4.5

5 years ago

3.4.5-1

5 years ago

3.4.5-0

5 years ago

3.4.4

5 years ago

3.4.4-0

5 years ago

3.4.3

5 years ago

3.4.3-0

5 years ago

3.4.2

5 years ago

3.4.2-1

5 years ago

3.4.2-0

5 years ago

3.4.1

5 years ago

3.4.1-0

5 years ago

3.4.0

5 years ago

3.4.0-0

5 years ago

3.3.11

5 years ago

3.3.11-0

5 years ago

3.3.10

5 years ago

3.3.10-0

5 years ago

3.3.9

5 years ago

3.3.9-0

5 years ago

3.3.8

5 years ago

3.3.8-0

5 years ago

3.3.7

5 years ago

3.3.7-0

5 years ago

3.3.6

5 years ago

3.3.6-0

5 years ago

3.3.5

5 years ago

3.3.5-1

5 years ago

3.3.5-0

5 years ago

3.3.4

5 years ago

3.3.4-0

5 years ago

3.3.3

5 years ago

3.3.3-0

5 years ago

3.3.2

5 years ago

3.3.1

5 years ago

3.3.1-0

5 years ago

3.3.0

5 years ago

3.3.0-0

5 years ago

3.2.4-0

5 years ago

3.2.3

5 years ago

3.2.3-0

5 years ago

3.2.2

5 years ago

3.2.2-1

5 years ago

3.2.2-0

5 years ago

3.2.1

5 years ago

3.2.1-0

5 years ago

3.2.0

5 years ago

3.2.0-2

5 years ago

3.2.0-1

5 years ago

3.2.0-0

5 years ago

3.1.0

5 years ago

3.1.0-2

5 years ago

3.1.0-1

5 years ago

3.1.0-0

5 years ago

3.0.11

5 years ago

3.0.11-0

5 years ago

3.0.10

5 years ago

3.0.10-0

5 years ago

3.0.9

5 years ago

3.0.9-0

5 years ago

3.0.8

5 years ago

3.0.8-0

5 years ago

3.0.7

5 years ago

3.0.7-0

5 years ago

3.0.6

5 years ago

3.0.6-0

5 years ago

3.0.5

5 years ago

3.0.5-0

5 years ago

3.0.4

6 years ago

3.0.4-0

6 years ago

3.0.3

6 years ago

3.0.3-0

6 years ago

3.0.2

6 years ago

3.0.2-2

6 years ago

3.0.2-1

6 years ago

3.0.2-0

6 years ago

3.0.1

6 years ago

3.0.1-0

6 years ago

3.0.0

6 years ago

2.0.1-0

6 years ago

2.0.0

6 years ago

2.0.0-0

6 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago