Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 38b0e9a

Browse files
abeisgoatJacob Wenger
authored andcommitted
Upgraded to the Firebase 3.x.x SDK (#717)
1 parent 39d8719 commit 38b0e9a

Some content is hidden

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

53 files changed

+3612
-1640
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ dist/
22
node_modules/
33
bower_components/
44
tests/coverage/
5-
.idea
5+
6+
.idea
7+
tests/key.json

.jshintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"predef": [
33
"angular",
4-
"Firebase"
4+
"firebase"
55
],
66
"bitwise": true,
77
"browser": true,

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ sudo: false
55
addons:
66
sauce_connect: true
77
before_install:
8+
- openssl aes-256-cbc -K $encrypted_d1b4272f4052_key -iv $encrypted_d1b4272f4052_iv
9+
-in tests/key.json.enc -out tests/key.json -d
810
- export CHROME_BIN=chromium-browser
911
- export DISPLAY=:99.0
1012
- sh -e /etc/init.d/xvfb start
@@ -17,10 +19,11 @@ before_script:
1719
- grunt install
1820
- phantomjs --version
1921
script:
20-
- sh ./tests/travis.sh
22+
- '[ -e tests/key.json ] && sh ./tests/travis.sh || false'
2123
after_script:
2224
- cat ./tests/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
2325
env:
2426
global:
27+
- ANGULARFIRE_TEST_DB_URL=https://angularfire-dae2e.firebaseio.com
2528
- secure: mGHp1rQI11OvbBQn3PnBT5kuyo26gFl8U+nNq0Ot4opgSBX9JaHqS8Dx63uALWWU9qjy08/Mn68t/sKhayH1+XrPDIenOy/XEkkSAG60qAAowD9dRo3WaIMSOcWWYDeqdZOAWZ3LiXvjLO4Swagz5ejz7UtY/ws4CcTi2n/fp7c=
2629
- secure: Eao+hPFWKrHb7qUGEzLg7zdTCE//gb3arf5UmI9Z3i+DydSu/AwExXuywJYUj4/JNm/z8zyJ3j1/mdTyyt9VVyrnQNnyGH1b2oCUHkrs1NLwh5Oe4YcqUYROzoEKdDInvmjVJnIfUEM07htGMGvsLsX4MW2tqVHvD2rOwkn8C9s=

Gruntfile.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ module.exports = function(grunt) {
9494
options: {
9595
configFile: 'tests/automatic_karma.conf.js'
9696
},
97-
manual: {
98-
configFile: 'tests/manual_karma.conf.js'
99-
},
10097
singlerun: {},
10198
watch: {
10299
autowatch: true,
@@ -145,7 +142,6 @@ module.exports = function(grunt) {
145142
grunt.registerTask('test', ['test:unit', 'test:e2e']);
146143
grunt.registerTask('test:unit', ['karma:singlerun']);
147144
grunt.registerTask('test:e2e', ['concat', 'connect:testserver', 'protractor:singlerun']);
148-
grunt.registerTask('test:manual', ['karma:manual']);
149145

150146
// Travis CI testing
151147
//grunt.registerTask('test:travis', ['build', 'test:unit', 'connect:testserver', 'protractor:saucelabs']);

README.md

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1+
# AngularFire [![Build Status](https://travis-ci.org/firebase/angularfire.svg?branch=master)](https://travis-ci.org/firebase/angularfire) [![Coverage Status](https://coveralls.io/repos/firebase/angularfire/badge.svg?branch=master&service=github)](https://coveralls.io/github/firebase/angularfire?branch=master) [![Version](https://badge.fury.io/gh/firebase%2Fangularfire.svg)](http://badge.fury.io/gh/firebase%2Fangularfire)
12

2-
# AngularFire
33

4-
[![Build Status](https://travis-ci.org/firebase/angularfire.svg?branch=master)](https://travis-ci.org/firebase/angularfire)
5-
[![Coverage Status](https://coveralls.io/repos/firebase/angularfire/badge.svg?branch=master&service=github)](https://coveralls.io/github/firebase/angularfire?branch=master)
6-
[![Version](https://badge.fury.io/gh/firebase%2Fangularfire.svg)](http://badge.fury.io/gh/firebase%2Fangularfire)
7-
[![Join Slack](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://firebase-community.appspot.com/)
8-
9-
AngularFire is the officially supported [AngularJS](http://angularjs.org/) binding for
10-
[Firebase](http://www.firebase.com/?utm_medium=web&utm_source=angularfire). Firebase is a
11-
backend service that provides data storage, authentication, and static website hosting for your Angular app.
4+
AngularFire is the officially supported [AngularJS](https://angularjs.org/) binding for
5+
[Firebase](https://firebase.google.com/). Firebase is a
6+
backend service that provides data storage, authentication, and static website hosting for your
7+
Angular app.
128

139
AngularFire is a complement to the core Firebase client. It provides you with three Angular
1410
services:
1511
* `$firebaseObject` - synchronized objects
1612
* `$firebaseArray` - synchronized collections
1713
* `$firebaseAuth` - authentication, user management, routing
1814

15+
Join our [Firebase + Angular Google Group](https://groups.google.com/forum/#!forum/firebase-angular)
16+
to ask questions, provide feedback, and share apps you've built with AngularFire.
17+
18+
19+
## Table of Contents
20+
21+
* [Getting Started With Firebase](#getting-started-with-firebase)
22+
* [Downloading AngularFire](#downloading-angularfire)
23+
* [Documentation](#documentation)
24+
* [Examples](#examples)
25+
* [Migration Guides](#migration-guides)
26+
* [Contributing](#contributing)
27+
28+
29+
## Getting Started With Firebase
30+
31+
AngularFire requires [Firebase](https://firebase.google.com/) in order to authenticate users and sync
32+
and store data. Firebase is a suite of integrated products designed to help you develop your app,
33+
grow your user base, and earn money. You can [sign up here for a free account](https://console.firebase.google.com/).
34+
1935

2036
## Downloading AngularFire
2137

@@ -26,18 +42,12 @@ In order to use AngularFire in your project, you need to include the following f
2642
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
2743

2844
<!-- Firebase -->
29-
<script src="https://cdn.firebase.com/js/client/2.4.0/firebase.js"></script>
45+
<script src="https://www.gstatic.com/firebasejs/3.0.3/firebase.js"></script>
3046

3147
<!-- AngularFire -->
32-
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
48+
<script src="https://cdn.firebase.com/libs/angularfire/2.0.0/angularfire.min.js"></script>
3349
```
3450

35-
Use the URL above to download both the minified and non-minified versions of AngularFire from the
36-
Firebase CDN. You can also download them from the
37-
[releases page of this GitHub repository](https://github.com/firebase/angularfire/releases).
38-
[Firebase](https://www.firebase.com/docs/web/quickstart.html?utm_medium=web&utm_source=angularfire) and
39-
[Angular](https://angularjs.org/) libraries can be downloaded directly from their respective websites.
40-
4151
You can also install AngularFire via npm and Bower and its dependencies will be downloaded
4252
automatically:
4353

@@ -49,28 +59,34 @@ $ npm install angularfire --save
4959
$ bower install angularfire --save
5060
```
5161

52-
Once you've included AngularFire and its dependencies into your project, you will have access to
53-
the `$firebase` service.
5462

63+
## Documentation
5564

56-
## Getting Started with Firebase
65+
* [Quickstart](docs/quickstart.md)
66+
* [Guide](docs/guide/README.md)
67+
* [API Reference](https://angularfire.firebaseapp.com/api.html)
5768

58-
AngularFire uses Firebase for data storage and authentication. You can [sign up here for a free
59-
account](https://www.firebase.com/signup/?utm_medium=web&utm_source=angularfire).
6069

70+
## Examples
6171

62-
## Documentation
72+
### Full Examples
6373

64-
The Firebase docs have a [quickstart](https://www.firebase.com/docs/web/bindings/angular/quickstart.html?utm_medium=web&utm_source=angularfire),
65-
[guide](https://www.firebase.com/docs/web/bindings/angular/guide?utm_medium=web&utm_source=angularfire),
66-
and [full API reference](https://www.firebase.com/docs/web/bindings/angular/api.html?utm_medium=web&utm_source=angularfire)
67-
for AngularFire.
74+
* [Wait And Eat](https://github.com/gordonmzhu/angular-course-demo-app-v2)
75+
* [TodoMVC](https://github.com/tastejs/todomvc/tree/master/examples/firebase-angular)
76+
* [Tic-Tac-Tic-Tac-Toe](https://github.com/jwngr/tic-tac-tic-tac-toe/)
77+
* [Firereader](http://github.com/firebase/firereader)
78+
* [Firepoker](https://github.com/Wizehive/Firepoker)
6879

69-
We also have a [tutorial](https://www.firebase.com/tutorial/#tutorial/angular/0?utm_medium=web&utm_source=angularfire)
70-
to help you get started with AngularFire.
80+
### Recipes
7181

72-
Join our [Firebase + Angular Google Group](https://groups.google.com/forum/#!forum/firebase-angular)
73-
to ask questions, provide feedback, and share apps you've built with AngularFire.
82+
* [Date Object To A Firebase Timestamp Using `$extend`](http://jsfiddle.net/katowulf/syuzw9k1/)
83+
* [Filter a `$FirebaseArray`](http://jsfiddle.net/firebase/ku8uL0pr/)
84+
85+
86+
## Migration Guides
87+
88+
* [Migrating from AngularFire `1.x.x` to `2.x.x`](docs/migration/1XX-to-2XX.md)
89+
* [Migrating from AngularFire `0.9.x` to `1.x.x`](docs/migration/09X-to-1XX.md)
7490

7591

7692
## Contributing

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
],
2727
"dependencies": {
2828
"angular": "^1.3.0",
29-
"firebase": "2.x.x"
29+
"firebase": "3.x.x"
3030
}
3131
}

docs/guide/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# AngularFire Guide
2+
3+
1. [Introduction to AngularFire](introduction-to-angularfire.md) - Learn about what AngularFire is and how to integrate it into your Angular app.
4+
2. [Synchronized Objects](synchronized-objects.md) - Create synchronized objects and experience three-way data binding.
5+
3. [Synchronized Arrays](synchronized-arrays.md) - Create and modify arrays which stay in sync with the database.
6+
4. [User Authentication](user-auth.md) - AngularFire handles user authentication and session management for you.
7+
5. [Extending the Services](extending-services.md) - Advanced users can extend the functionality of the built-in AngularFire services.
8+
6. [Beyond AngularFire](beyond-angularfire.md) - AngularFire is not the only way to use Angular and Firebase together.

docs/guide/beyond-angularfire.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Beyond AngularFire | AngularFire Guide
2+
3+
## Table of Contents
4+
5+
* [Overview](#overview)
6+
* [Best Practices](#best-practices)
7+
* [Deploying Your App](#deploying-your-app)
8+
* [Next Steps](#next-steps)
9+
10+
11+
## Overview
12+
13+
AngularFire greatly simplifies bindings and abstracts a lot of the internal workings of Angular,
14+
such as how to notify the compiler when changes occur. However, it does not attempt to replicate
15+
the entire Firebase client library's API.
16+
17+
There are plenty of use cases for dropping down to the SDK level and using it directly. This
18+
section will cover a few best practices and techniques for grabbing data directly from our
19+
database using the JavaScript client library.
20+
21+
This is easiest to accomplish with an example, so read the comments carefully.
22+
23+
```js
24+
app.controller("SampleCtrl", ["$scope", "$timeout", function($scope, $timeout) {
25+
// create a reference to our Firebase database
26+
var ref = firebase.database.ref();
27+
28+
// read data from the database into a local scope variable
29+
ref.on("value", function(snapshot) {
30+
// Since this event will occur outside Angular's $apply scope, we need to notify Angular
31+
// each time there is an update. This can be done using $scope.$apply or $timeout. We
32+
// prefer to use $timeout as it a) does not throw errors and b) ensures all levels of the
33+
// scope hierarchy are refreshed (necessary for some directives to see the changes)
34+
$timeout(function() {
35+
$scope.data = snapshot.val();
36+
});
37+
});
38+
}]);
39+
```
40+
41+
Synchronizing simple data like this is trivial. When we start operating on synchronized arrays
42+
and dealing with bindings, things get a little more interesting. For a comparison of the
43+
bare-bones work needed to synchronize an array, examine
44+
[a naive comparison of AngularFire versus the vanilla Firebase client library](https://gist.github.com/katowulf/a8466f4d66a4cea7af7c), and look at
45+
[Firebase.getAsArray()](https://github.com/katowulf/Firebase.getAsArray) for a more
46+
fully functional synchronized array implementation and the work involved.
47+
48+
49+
## Best Practices
50+
51+
When using the vanilla Firebase client library with Angular, it is best to keep the following things
52+
in mind:
53+
54+
* **Wrap events in `$timeout()`**: Wrap all server notifications in
55+
`$timeout()` to ensure the Angular compiler is notified of changes.
56+
* **Use `$window.Firebase`**: This allows test units and end-to-end
57+
tests to spy on the Firebase client library and replace it with mock functions. It also avoids the linter warnings about
58+
globals.
59+
* **Mock Firebase for testing**: Use mocks for unit tests. A non-supported,
60+
third-party mock of the Firebase classes can be
61+
[found here](https://github.com/katowulf/mockfirebase). The
62+
[AngularFire unit tests](https://github.com/firebase/angularfire/blob/master/tests/unit)
63+
can be used as an example of mocking `Firebase` classes.
64+
65+
66+
## Deploying Your App
67+
68+
Once you are done building your application, you'll need a way to share it with the world. To
69+
deploy your Angular applications free, fast, and without fuss, do it Firebase style! Our
70+
production-grade hosting service serves your content over HTTPS and is backed by a global CDN.
71+
You can deploy your application for free at your very own subdomain of `firebaseapp.com`
72+
or you can host it at any custom domain on one of our paid plans. Check out
73+
[Firebase Hosting](https://firebase.google.com/docs/hosting/) for more information.
74+
75+
76+
## Next Steps
77+
78+
There are many additional resources for learning about using Firebase with Angular applications:
79+
80+
* Browse the [AngularFire API documentation](https://angularfire.firebaseapp.com/api.html).
81+
* The [`angularfire-seed`](https://github.com/firebase/angularfire-seed) repo contains a template
82+
project to help you get started.
83+
* Check out the [various examples that use AngularFire](../README.md).
84+
* Join our [AngularFire mailing list](https://groups.google.com/forum/#!forum/firebase-angular) to
85+
keep up to date with any announcements and learn from the AngularFire community.
86+
* The [`angularfire` tag on Stack Overflow](http://stackoverflow.com/questions/tagged/angularfire)
87+
has answers to a lot of code-related questions.

0 commit comments

Comments
 (0)