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

rxjsfirebase

v3.2.7

Published

RxJS Beta 5 wrapper around firebase

Downloads

20

Readme

#RXJS 5 (beta currently at Beta 2) wrapper around Firebase's API.

Great with Angular2! Install using npm

npm install rxjsfirebase --save

This project was built with TypeScript To create an instance, you'll simply have to supply a native Firebase object to the constructor

    import {RxFirebase, EventType} from 'rxjsfirebase'
    import * as Firebase from 'firebase'
    
    var rootref = new Firebase("MY_FIREBASE_URL");
    var rx_rootRef = new RxFirebase(firebase);

I tried to port almost all the methods to be Observable friendly.

#Returning Child Paths and Queries

Getting a child path is exactly the same as the original objects. You can always call

child(mySubPath)

orderByChild(childPath)

orderByKey(key)

orderByValue(val)

orderByPriority()

startAt

endAt

equalTo

limitToFirst

limitToLast

limit

ref

#Observing Values

You'll need to import the modules EventType enum. The enum as these values:

EventType.CHILD_ADDED

EventType.CHILD_REMOVED

EventType.CHILD_MOVED

EventType.CHILD_REMOVED

EventType.VALUE

    import {EventType} from 'rxjsfirebase'

    rx_rootref.rx_observe(EventType.CHILD_ADDED)
        .subscribe((snapshot) => {
            console.log("Completed observing snapshot: ", snapshot.val())
        }, (err) => {
            console.log(err)
        })

#Observing Values Once

To keep respectful to RxJS, we simply just fire a take(1) to observe the value once.

    rx_rootref.rx_observe(EventType.CHILD_ADDED).take(1)
        .subscribe((snapshot) => {
            console.log("Completed observing snapshot just once: ", snapshot.val())
        }, (err) => {
            console.log(err)
        })

#Observing Values with a Sister Key

This is actually a separate method: rx_observeWithSiblingKey and it returns an object with the keys snapshot and siblingKey Remember the sibling key might be null

    rx_rootref.rx_observeWithSiblingKey(EventType.CHILD_ADDED)
        .subscribe(snapshotWithKey => {
            console.log("snapshot", snapshotWithKey.snapshot)
            console.log("siblingKey (might be null!)", snapshotWithKey.siblingKey)
        })

#Observing Auth Values

This will return the authData. This does not throw an error if you are not authenticated.

    rx_rootRef.rx_observeAuth().subscribe(authData => {
        if (authData) {
            console.log("User " + authData.uid + " is logged in with " + authData.provider);
        } else {
            console.log("User is logged out");
        }
    })

#Setting Values

But this one will wrap that callback into an Observable

    rx_rootref.rx_set(myValue)
        .subscribe(() => {
            console.log("Completed setting the value at this ref")
        }, (err) => {
            console.log(err)
        })

#Updating Values

But this one will wrap that callback into an Observable<{}>

    rx_rootref.rx_update(valuesToUpdate)
        .subscribe(() => {
            console.log("Completed updating values at this ref")
        }, (err) => {
            console.log(err)
        })

#Push Values

But this one will wrap that callback into an Observable<RxFirebase> The RxFirebase instance is the location of the new ref that was pushed

    rx_rootref.rx_push(myValue)
        .subscribe(newFirebaseRef => {
            console.log("Completed pushing and it's located at this ref", newFirebaseRef)
        }, (err) => {
            console.log(err)
        })