Skip to content

Commit 6d5daab

Browse files
jamesdanielsdavideast
authored andcommitted
Starting the 4.0.0-rc0 doc changes
1 parent a262a5c commit 6d5daab

File tree

4 files changed

+50
-49
lines changed

4 files changed

+50
-49
lines changed

docs/1-install-and-setup.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ You can optionally provide a custom FirebaseApp name with `initializeApp`.
9595
@NgModule({
9696
imports: [
9797
BrowserModule,
98-
AngularFireModule.initializeApp(firebaseConfig, authConfig, 'my-app-name')
98+
AngularFireModule.initializeApp(firebaseConfig, 'my-app-name')
9999
],
100100
declarations: [ AppComponent ],
101101
bootstrap: [ AppComponent ]
@@ -110,7 +110,8 @@ Open `/src/app/app.component.ts`, and make sure to modify/delete any tests to ge
110110

111111
```ts
112112
import { Component } from '@angular/core';
113-
import { AngularFire, FirebaseListObservable } from 'angularfire2';
113+
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
114+
114115

115116
@Component({
116117

@@ -119,7 +120,7 @@ import { AngularFire, FirebaseListObservable } from 'angularfire2';
119120
styleUrls: ['app.component.css']
120121
})
121122
export class AppComponent {
122-
constructor(af: AngularFire) {
123+
constructor(db: AngularFireDatabase) {
123124

124125
}
125126
}
@@ -132,7 +133,7 @@ In `/src/app/app.component.ts`:
132133

133134
```ts
134135
import { Component } from '@angular/core';
135-
import { AngularFire, FirebaseListObservable } from 'angularfire2';
136+
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
136137

137138
@Component({
138139

@@ -142,8 +143,8 @@ import { AngularFire, FirebaseListObservable } from 'angularfire2';
142143
})
143144
export class AppComponent {
144145
items: FirebaseListObservable<any[]>;
145-
constructor(af: AngularFire) {
146-
this.items = af.database.list('/items');
146+
constructor(db: AngularFireDatabase) {
147+
this.items = db.list('/items');
147148
}
148149
}
149150
```

docs/2-retrieving-data-as-objects.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you've followed the earlier step "Installation and Setup" your `/src/app/app
1414

1515
```ts
1616
import { Component } from '@angular/core';
17-
import { AngularFire, FirebaseListObservable } from 'angularfire2';
17+
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
1818

1919
@Component({
2020
selector: 'app-root',
@@ -23,8 +23,8 @@ import { AngularFire, FirebaseListObservable } from 'angularfire2';
2323
})
2424
export class AppComponent {
2525
items: FirebaseListObservable<any[]>;
26-
constructor(af: AngularFire) {
27-
this.items = af.database.list('items');
26+
constructor(db: AngularFireDatabase) {
27+
this.items = db.list('items');
2828
}
2929
}
3030
```
@@ -42,9 +42,9 @@ There are two ways to create an object binding:
4242

4343
```ts
4444
// relative URL, uses the database url provided in bootstrap
45-
const relative = af.database.object('/item');
45+
const relative = db.object('/item');
4646
// absolute URL
47-
const absolute = af.database.object('https://<your-app>.firebaseio.com/item');
47+
const absolute = db.object('https://<your-app>.firebaseio.com/item');
4848
```
4949

5050
### Retrieve data
@@ -56,8 +56,8 @@ Replace the FirebaseListObservable to FirebaseObjectObservable in your `/src/app
5656
Also notice the templateUrl changed to inline template below:
5757

5858
```ts
59-
import {Component} from '@angular/core';
60-
import {AngularFire, FirebaseObjectObservable} from 'angularfire2';
59+
import { Component } from '@angular/core';
60+
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database';
6161

6262
@Component({
6363
selector: 'app-root',
@@ -67,8 +67,8 @@ import {AngularFire, FirebaseObjectObservable} from 'angularfire2';
6767
})
6868
export class AppComponent {
6969
item: FirebaseObjectObservable<any>;
70-
constructor(af: AngularFire) {
71-
this.item = af.database.object('/item');
70+
constructor(db: AngularFireDatabase) {
71+
this.item = db.object('/item');
7272
}
7373
}
7474
```
@@ -94,7 +94,7 @@ The promise can be useful to chain multiple operations, catching possible errors
9494
from security rules denials, or for debugging.
9595

9696
```ts
97-
const promise = af.database.object('/item').remove();
97+
const promise = db.object('/item').remove();
9898
promise
9999
.then(_ => console.log('success'))
100100
.catch(err => console.log(err, 'You dont have access!'));
@@ -105,7 +105,7 @@ promise
105105
Use the `set()` method for **destructive updates**.
106106

107107
```ts
108-
const itemObservable = af.database.object('/item');
108+
const itemObservable = db.object('/item');
109109
itemObservable.set({ name: 'new name!'});
110110
```
111111

@@ -114,7 +114,7 @@ itemObservable.set({ name: 'new name!'});
114114
Use the `update()` method for **non-destructive updates**.
115115

116116
```ts
117-
const itemObservable = af.database.object('/item');
117+
const itemObservable = db.object('/item');
118118
itemObservable.update({ age: newAge });
119119
```
120120

@@ -125,15 +125,15 @@ using an update with a primitive is the exact same as doing a `.set()` with a pr
125125
Use the `remove()` method to remove data at the object's location.
126126

127127
```ts
128-
const itemObservable = af.database.object('/item');
128+
const itemObservable = db.object('/item');
129129
itemObservable.remove();
130130
```
131131

132132
**Example app**:
133133

134134
```ts
135135
import { Component } from '@angular/core';
136-
import { AngularFire, FirebaseObjectObservable } from 'angularfire2';
136+
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database';
137137

138138
@Component({
139139
selector: 'app-root',
@@ -149,8 +149,8 @@ import { AngularFire, FirebaseObjectObservable } from 'angularfire2';
149149
})
150150
export class AppComponent {
151151
item: FirebaseObjectObservable<any>;
152-
constructor(af: AngularFire) {
153-
this.item = af.database.object('/item');
152+
constructor(db: AngularFireDatabase) {
153+
this.item = db.object('/item');
154154
}
155155
save(newName: string) {
156156
this.item.set({ name: newName });
@@ -177,7 +177,7 @@ Data retrieved from the object binding contains special properties retrieved fro
177177
AngularFire2 unwraps the Firebase DataSnapshot by default, but you can get the data as the original snapshot by specifying the `preserveSnapshot` option.
178178

179179
```ts
180-
this.item = af.database.object('/item', { preserveSnapshot: true });
180+
this.item = db.object('/item', { preserveSnapshot: true });
181181
this.item.subscribe(snapshot => {
182182
console.log(snapshot.key)
183183
console.log(snapshot.val())

docs/3-retrieving-data-as-lists.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Replace your `/src/app/app.component.ts` from previous step to look like below.
1515

1616
```ts
1717
import { Component } from '@angular/core';
18-
import { AngularFire } from 'angularfire2';
18+
import { AngularFireDatabase } from 'angularfire2/database';
1919

2020
@Component({
2121
selector: 'app-root',
2222
templateUrl: 'app.component.html',
2323
styleUrls: ['app.component.css']
2424
})
2525
export class AppComponent {
26-
constructor(af: AngularFire) {
26+
constructor(db: AngularFireDatabase) {
2727

2828
}
2929
}
@@ -33,7 +33,7 @@ In this section, we're going to modify the `/src/app/app.component.ts` to retre
3333

3434
## Create a list binding
3535

36-
Data is retrieved through the `af.database` service.
36+
Data is retrieved through the `AngularFireDatabase` module.
3737

3838
There are three ways to create a list binding:
3939

@@ -43,11 +43,11 @@ There are three ways to create a list binding:
4343

4444
```ts
4545
// relative URL, uses the database url provided in bootstrap
46-
const relative = af.database.list('/items');
46+
const relative = db.list('/items');
4747
// absolute URL
48-
const absolute = af.database.list('https://<your-app>.firebaseio.com/items');
48+
const absolute = db.list('https://<your-app>.firebaseio.com/items');
4949
// query
50-
const queryList = af.database.list('/items', {
50+
const queryList = db.list('/items', {
5151
query: {
5252
limitToLast: 10,
5353
orderByKey: true
@@ -63,8 +63,8 @@ Then in your template, you can use the `async` pipe to unwrap the binding.
6363
Update `/src/app/app.component.ts` to import `FirebaseListObservable` from angularfire2 and iterate thru the list once data is retrieved. Also note the change in attribute `templateUrl` to inline `template` below.
6464

6565
```ts
66-
import {Component} from '@angular/core';
67-
import {AngularFire, FirebaseListObservable} from 'angularfire2';
66+
import { Component } from '@angular/core';
67+
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
6868

6969
@Component({
7070
selector: 'app-root',
@@ -78,8 +78,8 @@ import {AngularFire, FirebaseListObservable} from 'angularfire2';
7878
})
7979
export class AppComponent {
8080
items: FirebaseListObservable<any>;
81-
constructor(af: AngularFire) {
82-
this.items = af.database.list('/items');
81+
constructor(db: AngularFireDatabase) {
82+
this.items = db.list('/items');
8383
}
8484
}
8585
```
@@ -105,7 +105,7 @@ The promise can be useful to chain multiple operations, catching possible errors
105105
from security rules denials, or for debugging.
106106

107107
```ts
108-
const promise = af.database.list('/items').remove();
108+
const promise = db.list('/items').remove();
109109
promise
110110
.then(_ => console.log('success'))
111111
.catch(err => console.log(err, 'You do not have access!'));
@@ -116,7 +116,7 @@ promise
116116
Use the `push()` method to add new items on the list.
117117

118118
```ts
119-
const items = af.database.list('/items');
119+
const items = db.list('/items');
120120
items.push({ name: newName });
121121
```
122122

@@ -125,7 +125,7 @@ items.push({ name: newName });
125125
Use the `update()` method to update existing items.
126126

127127
```ts
128-
const items = af.database.list('/items');
128+
const items = db.list('/items');
129129
// to get a key, check the Example app below
130130
items.update('key-of-some-data', { size: newSize });
131131
```
@@ -134,7 +134,7 @@ items.update('key-of-some-data', { size: newSize });
134134
Use the `remove()` method to remove data at the list item's location.
135135

136136
```ts
137-
const items = af.database.list('/items');
137+
const items = db.list('/items');
138138
// to get a key, check the Example app below
139139
items.remove('key-of-some-data');
140140
```
@@ -144,15 +144,15 @@ items.remove('key-of-some-data');
144144
If you omit the `key` parameter from `.remove()` it deletes the entire list.
145145

146146
```ts
147-
const items = af.database.list('/items');
147+
const items = db.list('/items');
148148
items.remove();
149149
```
150150

151151
**Example app**
152152

153153
```ts
154154
import { Component } from '@angular/core';
155-
import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2';
155+
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
156156

157157
@Component({
158158
selector: 'app-root',
@@ -171,8 +171,8 @@ import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'a
171171
})
172172
export class AppComponent {
173173
items: FirebaseListObservable<any>;
174-
constructor(af: AngularFire) {
175-
this.items = af.database.list('/messages');
174+
constructor(db: AngularFireDatabase) {
175+
this.items = db.list('/messages');
176176
}
177177
addItem(newName: string) {
178178
this.items.push({ text: newName });
@@ -201,7 +201,7 @@ Data retrieved from the object binding contains special properties retrieved fro
201201
AngularFire2 unwraps the Firebase DataSnapshot by default, but you can get the data as the original snapshot by specifying the `preserveSnapshot` option.
202202

203203
```ts
204-
this.items = af.database.list('/items', { preserveSnapshot: true });
204+
this.items = db.list('/items', { preserveSnapshot: true });
205205
this.items
206206
.subscribe(snapshots => {
207207
snapshots.forEach(snapshot => {

docs/4-querying-lists.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ observables emit new values, the query is automatically re-run.
99
Queries are created by specifying a `query` object on the `FirebaseListObservable` options.
1010

1111
```ts
12-
const queryObservable = af.database.list('/items', {
12+
const queryObservable = db.list('/items', {
1313
query: {
1414
orderByChild: 'size',
1515
equalTo: 'large'
@@ -40,7 +40,7 @@ const queryObservable = af.database.list('/items', {
4040

4141
```ts
4242
// WARNING: Do not copy and paste. This will not work!
43-
const queryObservable = af.database.list('/items', {
43+
const queryObservable = db.list('/items', {
4444
query: {
4545
orderByChild: 'size',
4646
equalTo: 'large',
@@ -53,7 +53,7 @@ You can only use `limitToFirst` or `limitToLast`, but not both in combination.
5353

5454
```ts
5555
// WARNING: Do not copy and paste. This will not work!
56-
const queryObservable = af.database.list('/items', {
56+
const queryObservable = db.list('/items', {
5757
query: {
5858
limitToFirst: 10,
5959
limitToLast: 100,
@@ -72,7 +72,7 @@ An RxJS Subject is imported below. A Subject is like an Observable, but can mult
7272

7373
```ts
7474
const subject = new Subject(); // import {Subject} from 'rxjs/Subject';
75-
const queryObservable = af.database.list('/items', {
75+
const queryObservable = db.list('/items', {
7676
query: {
7777
orderByChild: 'size',
7878
equalTo: subject
@@ -95,7 +95,7 @@ subject.next('small');
9595

9696
```ts
9797
import { Component } from '@angular/core';
98-
import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2';
98+
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
9999
import { Subject } from 'rxjs/Subject';
100100

101101
@Component({
@@ -118,9 +118,9 @@ export class AppComponent {
118118
items: FirebaseListObservable<any[]>;
119119
sizeSubject: Subject<any>;
120120

121-
constructor(af: AngularFire) {
121+
constructor(db: AngularFireDatabase) {
122122
this.sizeSubject = new Subject();
123-
this.items = af.database.list('/items', {
123+
this.items = db.list('/items', {
124124
query: {
125125
orderByChild: 'size',
126126
equalTo: this.sizeSubject

0 commit comments

Comments
 (0)