npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rxfire-kaladivo

v4.0.0

Published

Firebase JavaScript library RxJS

Downloads

31

Readme

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 firebase from 'firebase/app';
import 'firebase/firestore';
import { collectionData } from 'rxfire/firestore';
import { tap } from 'rxjs/operators';

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

collectionData(citiesRef, '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 firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/storage';
import { collectionData } from 'rxfire/firestore';
import { getDownloadURL } from 'rxfire/storage';
import { switchMap } from 'rxjs/operators';

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

collectionData(citiesRef, 'id')
  .pipe(
    switchMap(cities => {
      return combineLatest(...cities.map(c => {
        const ref = storage.ref(`/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 firebase from 'firebase/app';
import 'firebase/storage'; // import only the features needed
import { getDownloadURL } from 'rxfire/storage';

const app = firebase.initializeApp({ /* config */ });
const ref = app.storage().ref('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';

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 firebase from 'firebase/app';
import 'firebase/storage';
import { getDownloadURL, put /* not used! */ } 'rxfire/storage';

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

const url$ = getDownloadURL(ref);

Documentation

Examples

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