Skip to content

Commit 8b3bcf1

Browse files
author
Maximilian Alexander
committed
updating readme
1 parent 11543ce commit 8b3bcf1

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

README.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
#RXJS 5 (beta currently at Beta 2) wrapper around Firebase's API.
1+
#RXJS 5 (beta currently at Beta 6) wrapper around Firebase's API.
22

3-
Great with Angular2! Install using npm
3+
Works great with Angular2! Install using npm, you don't need typings since it's already packaged with the project.
44

55
`npm install rxjsfirebase --save`
66

7-
**This project was built with TypeScript**
7+
**Works on ES5 but also with ES6 and TypeScript**
88
To create an instance, you'll simply have to supply a native Firebase object to the constructor
99

1010
```javascript
11-
import {RxFirebase, EventType} from 'rxjsfirebase'
12-
import * as Firebase from 'firebase'
13-
14-
var rootref = new Firebase("MY_FIREBASE_URL");
15-
var rx_rootRef = new RxFirebase(firebase);
11+
import {RxFirebaseApp, RxFirebaseAuth, RxFirebaseView, EventType} from 'rxjsfirebase'
12+
13+
var config = config = {
14+
apiKey: '<your-api-key>',
15+
authDomain: '<your-auth-domain>',
16+
databaseURL: '<your-database-url>',
17+
storageBucket: '<your-storage-bucket>'
18+
}
19+
20+
var applicationInstance = new RxFirebaseApp(config);
21+
// or you can give the instance a name:
22+
var applicationInstance = new RxFirebaseApp(config, "myAppInstanceName");
1623
```
17-
18-
I tried to port almost all the methods to be Observable friendly.
1924

20-
#Returning Child Paths and Queries
25+
#Note
2126

22-
Getting a child path is exactly the same as the original objects. You can always call
27+
I made an opinionated effort to name data-endpoints as **RxFirebaseView**.
28+
The RxFirebaseView is essentially a `ref` or `query` in the old Firebase documentation.
29+
The logic is that it's some sort of database-path location that you can observe.
30+
It has all the methods that you love like
2331

2432
`child(mySubPath)`
2533

@@ -43,7 +51,7 @@ Getting a child path is exactly the same as the original objects. You can always
4351

4452
`limit`
4553

46-
`ref`
54+
4755

4856
#Observing Values
4957

@@ -63,7 +71,7 @@ The enum as these values:
6371
```javascript
6472
import {EventType} from 'rxjsfirebase'
6573

66-
rx_rootref.rx_observe(EventType.CHILD_ADDED)
74+
viewReference.rx_observe(EventType.CHILD_ADDED)
6775
.subscribe((snapshot) => {
6876
console.log("Completed observing snapshot: ", snapshot.val())
6977
}, (err) => {
@@ -74,10 +82,10 @@ The enum as these values:
7482

7583
#Observing Values Once
7684

77-
To keep respectful to RxJS, we simply just fire a `take(1)` to observe the value once.
85+
To keep the API respectful to RxJS, we simply just fire a `take(1)` to observe the value once.
7886

7987
```javascript
80-
rx_rootref.rx_observe(EventType.CHILD_ADDED).take(1)
88+
viewReference.rx_observe(EventType.CHILD_ADDED).take(1)
8189
.subscribe((snapshot) => {
8290
console.log("Completed observing snapshot just once: ", snapshot.val())
8391
}, (err) => {
@@ -88,9 +96,10 @@ To keep respectful to RxJS, we simply just fire a `take(1)` to observe the value
8896
#Observing Values with a Sister Key
8997

9098
This is actually a separate method: `rx_observeWithSiblingKey` and it returns an object with the keys `snapshot` and `siblingKey`
91-
Remember the sibling key might be `null`
99+
** Remember the sibling key might be `null` **
100+
92101
```javascript
93-
rx_rootref.rx_observeWithSiblingKey(EventType.CHILD_ADDED)
102+
viewReference.rx_observeWithSiblingKey(EventType.CHILD_ADDED)
94103
.subscribe(snapshotWithKey => {
95104
console.log("snapshot", snapshotWithKey.snapshot)
96105
console.log("siblingKey (might be null!)", snapshotWithKey.siblingKey)
@@ -102,7 +111,7 @@ Remember the sibling key might be `null`
102111
This will return the authData. This does not throw an error if you are not authenticated.
103112

104113
```javascript
105-
rx_rootRef.rx_observeAuth().subscribe(authData => {
114+
applicationInstance.auth.rx_observeAuth().subscribe(authData => {
106115
if (authData) {
107116
console.log("User " + authData.uid + " is logged in with " + authData.provider);
108117
} else {
@@ -116,7 +125,7 @@ This will return the authData. This does not throw an error if you are not authe
116125
But this one will wrap that callback into an Observable
117126

118127
```javascript
119-
rx_rootref.rx_set(myValue)
128+
viewReference.rx_set(myValue)
120129
.subscribe(() => {
121130
console.log("Completed setting the value at this ref")
122131
}, (err) => {
@@ -129,7 +138,7 @@ But this one will wrap that callback into an Observable
129138
But this one will wrap that callback into an `Observable<{}>`
130139

131140
```javascript
132-
rx_rootref.rx_update(valuesToUpdate)
141+
viewReference.rx_update(valuesToUpdate)
133142
.subscribe(() => {
134143
console.log("Completed updating values at this ref")
135144
}, (err) => {
@@ -139,11 +148,11 @@ But this one will wrap that callback into an `Observable<{}>`
139148

140149
#Push Values
141150

142-
But this one will wrap that callback into an `Observable<RxFirebase>`
151+
But this one will wrap that callback into an `Observable<RxFirebaseView>`
143152
The RxFirebase instance is the location of the new ref that was pushed
144153

145154
```javascript
146-
rx_rootref.rx_push(myValue)
155+
viewReference.rx_push(myValue)
147156
.subscribe(newFirebaseRef => {
148157
console.log("Completed pushing and it's located at this ref", newFirebaseRef)
149158
}, (err) => {

0 commit comments

Comments
 (0)