Skip to content

Commit 274b4da

Browse files
jamesdanielsdavideast
authored andcommitted
Before / after and more cleanup
1 parent 3d94861 commit 274b4da

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

docs/version-4-upgrade.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ Prior to 4.0, AngularFire2 not take advantage of the Firebase SDK's modularity f
1111
* `AngularFireDatabaseModule`
1212
* `AngularFireAuthModule`
1313

14-
Rather than inject `AngularFire` you should now inject each module independently:
14+
When upgrading, replace calls to `AngularFire.database` and `AngularFire.auth` with `AngularFireDatabase` and `AngularFireAuth` respectively.
1515

1616
```typescript
17-
import { AngularFireDatabase } from 'angularfire2/database';
18-
19-
...
17+
constructor(af: AngularFire) {
18+
af.database.list('foo');
19+
af.auth;
20+
}
21+
```
22+
Should now be:
2023

21-
constructor(db: AngularFireDatabase) {
24+
```typescript
25+
constructor(db: AngularFireDatabasem, afAuth: AngularFireAuth) {
2226
db.list('foo');
27+
afAuth.authState;
2328
}
2429
```
2530

2631
### Simplified Authentication API
2732

28-
In 4.0 we've reduced the complexity of the auth module by providing a [`firebase.User`](https://firebase.google.com/docs/reference/js/firebase.User) observer and cutting the methods that were wrapping the Firebase SDK.
33+
In 4.0 we've reduced the complexity of the auth module by providing only a [`firebase.User`](https://firebase.google.com/docs/reference/js/firebase.User) observer (`AngularFireAuth.authState`) and cutting the methods that were wrapping the Firebase SDK.
2934

3035
```typescript
3136
import { AngularFireAuth } from 'angularfire2/auth';
@@ -40,9 +45,7 @@ constructor(afAuth: AngularFireAuth) {
4045

4146
AngularFire2 exposes the raw Firebase Auth object via `AngularFireAuth.auth`. For actions like login, logout, user creation, etc. you should use the [methods available to `firebase.auth.Auth`](https://firebase.google.com/docs/reference/js/firebase.auth.Auth).
4247

43-
#### Removing pre-configured login
44-
45-
While convenient, the pre-configure login feature added unneeded complexity. `AngularFireModule.initializeApp` no longer takes a default sign in method. Sign in should be done with the Firebase SDK via `firebase.auth.Auth`:
48+
While convenient, the pre-configured login feature added unneeded complexity. `AngularFireModule.initializeApp` no longer takes a default sign in method. Sign in should be done with the Firebase SDK via `firebase.auth.Auth`:
4649

4750
```typescript
4851
login() {

0 commit comments

Comments
 (0)