Update version-4-upgrade.md #2
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Upgrading to AngularFire2 4.0
AngularFire2 4.0 is a refactor of the AngularFire2 package which implements
@NgModule, simplifies authentication, and better supports Angular 4.
Removing
AngularFire
for ModularityPrior to 4.0, AngularFire2 did not take advantage of the Firebase SDK's modularity for tree shaking. The
AngularFire
service has now been removed and the library is broken up into smaller@NgModule
s:AngularFireModule
AngularFireDatabaseModule
AngularFireAuthModule
When upgrading, replace calls to
AngularFire.database
andAngularFire.auth
withAngularFireDatabase
andAngularFireAuth
respectively.Should now be:
Simplified Authentication API
In 4.0 we've reduced the complexity of the auth module by providing only
firebase.User
observers (AngularFireAuth.authState
,AngularFireAuth.idToken
) and cutting the methods that were wrapping the Firebase SDK.AngularFire2 exposes the raw Firebase Auth object via
AngularFireAuth.auth
. For actions like login, logout, user creation, etc. you should use the methods available tofirebase.auth.Auth
.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 viafirebase.auth.Auth
:FirebaseListFactory and FirebaseObjectFactory API Changes
If you directly use
FirebaseListFactory
orFirebaseObjectFactory
you will no longer be able to pass in a string, it will instead expect a Firebase database reference.Putting this all together
Here's an example of what AngularFire2 4.0 looks like:
Checklist
yarn install
,yarn test
run successfully? (yes/no; required)Description
Code sample