Skip to content

Commit f277779

Browse files
authored
refactor(db): WIP new database API
refactor(db): WIP new database API
2 parents 0885173 + 27c857d commit f277779

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1864
-1270
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ npm-debug.log
99
angularfire2-*.tgz
1010
*.ngfactory.ts
1111
*.ngsummary.json
12+
*.bak
13+
.DS_Store

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ language: node_js
22
sudo: false
33
node_js:
44
- 'node'
5-
dist: precise
65

76
addons:
8-
firefox: latest
7+
chrome: stable
98
apt:
109
sources:
1110
- ubuntu-toolchain-r-test
@@ -27,7 +26,7 @@ before_script:
2726

2827
script:
2928
- npm run build
30-
- ./node_modules/.bin/karma start --single-run --browsers Firefox --reporters mocha
29+
- ./node_modules/.bin/karma start --single-run --browsers Chrome --reporters mocha
3130
# Run integration test to make sure our typings are correct for user-land.
3231
- node tools/run-typings-test.js
3332

README.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
<p align="center">
2-
<h1 align="center">AngularFire2</h1>
3-
<p align="center">The official library for Firebase and Angular 2</p>
2+
<h1 align="center">AngularFire</h1>
3+
<p align="center">The official library for Firebase and Angular</p>
44
</p>
55

66
[![Build Status](https://travis-ci.org/angular/angularfire2.svg?branch=master)](https://travis-ci.org/angular/angularfire2) [![Join the chat at https://gitter.im/angular/angularfire2](https://badges.gitter.im/angular/angularfire2.svg)](https://gitter.im/angular/angularfire2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
77

88
Status: Release candidate
99

10-
## What is AngularFire2?
10+
## What is AngularFire?
1111

12-
- **Observable based** - Use the power of rxjs, Angular 2, and Firebase.
13-
- **Realtime bindings** - Synchronize database collections as objects or lists.
14-
- **Authentication** - Monitor authentication state in realtime.
12+
- **Observable based** - Use the power of RxJS, Angular, and Firebase.
13+
- **Realtime bindings** - Synchronize data in reatime.
14+
- **Authentication** - Log users in with a variety of providers and monitor authentication state in realtime.
15+
- **ngrx friendly** - Integrate with ngrx using AngularFire's action based APIs.
1516

1617
#### Quick links
1718
[Contributing](CONTRIBUTING.md)
1819

1920
[Stackblitz Template](https://stackblitz.com/edit/angular-2ed5zx?) - Remember to set your Firebase configuration in `app/app.module.ts`.
2021

21-
[Upgrading to v4.0? Check out our guide.](docs/version-4-upgrade.md)
22+
[Upgrading to v5.0? Check out our guide.](docs/version-5-upgrade.md)
2223

2324
## Install
2425

@@ -30,7 +31,8 @@ npm install firebase angularfire2 --save
3031

3132
```ts
3233
import { Component } from '@angular/core';
33-
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
34+
import { AngularFireDatabase } from 'angularfire2/database';
35+
import { Observable } from 'rxjs/Observable';
3436

3537
@Component({
3638
selector: 'project-name-app',
@@ -43,23 +45,29 @@ import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/databa
4345
`
4446
})
4547
export class MyApp {
46-
items: FirebaseListObservable<any[]>;
48+
items: Observable<any[]>;
4749
constructor(db: AngularFireDatabase) {
48-
this.items = db.list('/items');
50+
this.items = db.list('items').valueChanges();
4951
}
5052
}
5153
```
5254

5355
## Developer Guide
54-
If you want to get started quickly on building with AngularFire2, check out our
55-
5 step developer guide that will teach you everything you need to know to be
56-
productive with AngularFire2.
57-
58-
1. [Installation & Setup](docs/1-install-and-setup.md)
59-
2. [Retrieving data as objects - FirebaseObjectObservable](docs/2-retrieving-data-as-objects.md)
60-
3. [Retrieving data as lists - FirebaseListObservable](docs/3-retrieving-data-as-lists.md)
61-
4. [Querying lists](docs/4-querying-lists.md)
62-
5. [User Authentication - FirebaseAuthentication](docs/5-user-authentication.md)
63-
6. [Using AngularFire2 with Ionic](docs/Auth-with-Ionic2.md)
64-
7. [Using AngularFire2 with Ionic and Angular 4](docs/Auth-with-Ionic3-Angular4.md)
65-
8. [Deploying AngularFire2 to FirebaseHosting](docs/7-deploying-angularfire-to-firebase.md)
56+
57+
### Getting started
58+
- [Installation & Setup](docs/1-install-and-setup.md)
59+
60+
### AngularFireDatabase
61+
- [Retrieving data as objects](docs/2-retrieving-data-as-objects.md)
62+
- [Retrieving data as lists](docs/3-retrieving-data-as-lists.md)
63+
- [Querying lists](docs/4-querying-lists.md)
64+
65+
### AngularFireAuth
66+
- [User Authentication](docs/5-user-authentication.md)
67+
68+
### Deploy to Firebase Hosting
69+
- [Deploying AngularFire to Firebase Hosting](docs/7-deploying-angularfire-to-firebase.md)
70+
71+
### Ionic
72+
- [Using AngularFire with Ionic 2](docs/Auth-with-Ionic2.md)
73+
- [Using AngularFire with Ionic 3 and Angular 4](docs/Auth-with-Ionic3-Angular4.md)

docs/1-install-and-setup.md

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
11
# 1. Installation and Setup
22

3-
> Getting started with AngularFire2 is easy with the [Angular CLI](https://github.com/angular/angular-cli). Follow the 10 steps below to get started. Don't worry, we're always working to make this shorter.
4-
53
> Using Ionic and the Ionic CLI? Check out these [specific instructions](6-angularfire-and-ionic-cli.md) for Ionic and their CLI.
64
75
### 0. Prerequisites
86

9-
Before you start installing AngularFire2, make sure you have latest version of angular-cli installed.
10-
To verify run the command `ng -v` and ensure you see `angular-cli: 1.x.x-beta.xx`. The lowest compatible version is `1.x.x-beta.14`.
11-
12-
If not, you may need to do the following:
7+
AngularFire provides multiple module formats for different types of builds. The guide is based off the Angular CLI. It is possible to do a manual setup with Webpack or a SystemJS build as well.
138

149
```bash
15-
# if you have the wrong cli version only
16-
npm uninstall -g angular-cli
17-
npm uninstall -g @angular/cli
18-
npm cache clean
19-
20-
# reinstall clean version
21-
npm install -g @angular/cli@latest
22-
```
23-
24-
You need the Angular CLI, typings, and TypeScript.
25-
26-
```bash
27-
npm install -g @angular/cli@latest
28-
# or install locally
29-
npm install @angular/cli --save-dev
30-
# make sure you have typings installed
31-
npm install -g typings
32-
npm install -g typescript
10+
npm install @angular/cli
3311
```
3412

3513
### 1. Create a new project
@@ -50,13 +28,13 @@ open http://localhost:4200
5028

5129
You should see a message that says *App works!*
5230

53-
### 3. Install AngularFire 2 and Firebase
31+
### 3. Install AngularFire and Firebase
5432

5533
```bash
5634
npm install angularfire2 firebase --save
5735
```
5836

59-
Now that you have a new project setup, install AngularFire2 and Firebase from npm.
37+
Now that you have a new project setup, install AngularFire and Firebase from npm.
6038

6139
### 4. Add Firebase config to environments variable
6240

@@ -79,6 +57,7 @@ export const environment = {
7957
### 5. Setup @NgModule for the AngularFireModule
8058

8159
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
60+
8261
This can be found in your project at [the Firebase Console](https://console.firebase.google.com):
8362

8463
```ts
@@ -177,17 +156,18 @@ In `/src/app/app.component.ts`:
177156

178157
```ts
179158
import { Component } from '@angular/core';
180-
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
159+
import { AngularFireDatabase } from 'angularfire2/database';
160+
import { Observable } from 'rxjs/Observable';
181161

182162
@Component({
183163
selector: 'app-root',
184164
templateUrl: 'app.component.html',
185165
styleUrls: ['app.component.css']
186166
})
187167
export class AppComponent {
188-
items: FirebaseListObservable<any[]>;
168+
items: Observable<any[]>;
189169
constructor(db: AngularFireDatabase) {
190-
this.items = db.list('/items');
170+
this.items = db.list('items').valueChanges();
191171
}
192172
}
193173
```
@@ -197,7 +177,7 @@ Open `/src/app/app.component.html`:
197177
```html
198178
<ul>
199179
<li class="text" *ngFor="let item of items | async">
200-
{{item.$value}}
180+
{{ item | json }}
201181
</li>
202182
</ul>
203183
```
@@ -214,33 +194,3 @@ And that's it! If it's totally *borked*, file an issue and let us know.
214194

215195
### [Next Step: Retrieving data as objects](2-retrieving-data-as-objects.md)
216196

217-
### Troubleshooting
218-
219-
#### 1. Cannot find namespace 'firebase'.
220-
221-
If you run into this error while trying to invoke `ng serve`, open `src/tsconfig.json` and add the "types" array as follows:
222-
223-
```json
224-
{
225-
"compilerOptions": {
226-
...
227-
"typeRoots": [
228-
"../node_modules/@types"
229-
],
230-
231-
// ADD THIS
232-
"types": [
233-
"firebase"
234-
]
235-
}
236-
}
237-
```
238-
239-
#### 2. Cannot find name 'require' (This is just a temporary workaround for the Angular CLI).
240-
241-
If you run into this error while trying to invoke `ng serve`, open `src/typings.d.ts` and add the following two entries as follows:
242-
243-
```bash
244-
declare var require: any;
245-
declare var module: any;
246-
```

0 commit comments

Comments
 (0)