Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"strict": true,
"trailing": true,
"undef": true,
"unused": true
"unused": true,
"esnext": true
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ and [read our docs for more information about indexing your data](https://www.fi
In order to use GeoFire in your project, you need to include the following files in your HTML:

```html
<!-- RSVP -->
<script src="rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>
Expand All @@ -92,7 +92,7 @@ Use the URL above to download both the minified and non-minified versions of Geo
Firebase CDN. You can also download them from the
[releases page of this GitHub repository](https://github.com/firebase/geofire-js/releases).
[Firebase](https://www.firebase.com/docs/web/quickstart.html?utm_source=geofire-js) and
[RSVP](https://github.com/tildeio/rsvp.js/) can be downloaded directly from their respective websites.
[ES6 Shim](https://github.com/paulmillr/es6-shim)

You can also install GeoFire via npm or Bower and its dependencies will be downloaded automatically:

Expand Down Expand Up @@ -395,7 +395,7 @@ var distance = GeoFire.distance(location1, location2); // distance === 12378.53

GeoFire uses promises when writing and retrieving data. Promises represent the result of a potentially long-running operation and allow code to run asynchronously. Upon completion of the operation, the promise will be "resolved" / "fulfilled" with the operation's result. This result will be passed to the function defined in the promise's `then()` method.

GeoFire uses the lightweight RSVP.js library to provide an implementation of JavaScript promises. If you are unfamiliar with promises, please refer to the [RSVP.js documentation](https://github.com/tildeio/rsvp.js/). Here is a quick example of how to consume a promise:
GeoFire uses the lightweight ES6 Shim library to provide a polyfill for the native implementation of JavaScript promises. If you are unfamiliar with promises, please refer to the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Here is a quick example of how to consume a promise:

```JavaScript
promise.then(function(result) {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"dependencies": {
"firebase": "2.x.x",
"rsvp": "3.1.x"
"es6-shim": "0.34.x"
},
"devDependencies": {
"jasmine": "~2.0.0"
Expand Down
5 changes: 0 additions & 5 deletions build/header
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,5 @@
* License: MIT
*/

// Include RSVP if this is being run in node
if (typeof module !== "undefined" && typeof process !== "undefined") {
var RSVP = require("rsvp");
}

var GeoFire = (function() {
"use strict";
4 changes: 2 additions & 2 deletions examples/fish1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

<!-- RSVP -->
<script src="js/vendor/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- GeoFire -->
<script src="js/vendor/geofire.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/fish1/js/fish1.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Once all the fish are in GeoFire, update some of their positions
var newLocation;
RSVP.allSettled(promises).then(function() {
Promise.all(promises).then(function() {
log("*** Updating locations ***");
newLocation = [-53.435719, 140.808716];
return geoFire.set("fish1", newLocation);
Expand Down
4 changes: 2 additions & 2 deletions examples/fish2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

<!-- RSVP -->
<script src="js/vendor/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- GeoFire -->
<script src="js/vendor/geofire.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/fish2/js/fish2.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
});

// Once all the fish are in GeoFire, log a message that the user can now move fish around
RSVP.allSettled(promises).then(function() {
Promise.all(promises).then(function() {
log("*** Use the controls above to move the fish in and out of the query ***");
});

Expand Down
4 changes: 2 additions & 2 deletions examples/fish3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

<!-- RSVP -->
<script src="js/vendor/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- GeoFire -->
<script src="js/vendor/geofire.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/fish3/js/fish3.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
});

// Once all the fish are in GeoFire, log a message that the user can now move fish around
RSVP.allSettled(promises).then(function() {
Promise.all(promises).then(function() {
log("*** Creating GeoQuery ***");
// Create a GeoQuery centered at fish2
var geoQuery = geoFire.query({
Expand Down
4 changes: 2 additions & 2 deletions examples/html5Geolocation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

<!-- RSVP -->
<script src="js/vendor/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- GeoFire -->
<script src="js/vendor/geofire.min.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions examples/queryBuilder/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

<!-- RSVP -->
<script src="js/vendor/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- GeoFire -->
<script src="js/vendor/geofire.min.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions examples/sfVehicles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ <h3>Download GeoFire</h3>
<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script>

<!-- RSVP -->
<script src="js/vendor/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="js/vendor/es6-shim.min.js"></script>

<!-- GeoFire -->
<script src="js/vendor/geofire.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var paths = {
config: "tests/karma.conf.js",
files: [
"bower_components/firebase/firebase.js",
"bower_components/rsvp/rsvp.min.js",
"bower_components/es6-shim/es6-shim.min.js",
"src/*.js",
"tests/specs/*.spec.js"
]
Expand Down
9 changes: 4 additions & 5 deletions migration/migrateToV3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var Firebase = require('firebase');
var RSVP = require('rsvp');
var args = process.argv

function usage() {
Expand All @@ -11,7 +10,7 @@ function usage() {
}

function setWithPromise(ref, value, priority) {
return new RSVP.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
if (priority) {
ref.setWithPriority(value, priority, function(error) {
if (error) {
Expand Down Expand Up @@ -52,7 +51,7 @@ function runMigration(fromFirebase, toFirebase, inPlace) {
var hash = parts[0];
var key = parts.splice(1).join(":");
(function(key, hash) {
var promise = new RSVP.Promise(function(resolve, reject) {
var promise = new Promise(function(resolve, reject) {
fromFirebase.child('l').child(key).once('value', function(snapshot) {
resolve(snapshot.val());
}, function(error) {
Expand All @@ -76,15 +75,15 @@ function runMigration(fromFirebase, toFirebase, inPlace) {
})(key, hash);
}
});
RSVP.all(promises).then(function(posts) {
Promise.all(promises).then(function(posts) {
if (error) {
console.log("There were errors migrating GeoFire, please check your data and the result manually");
process.exit(1);
} else {
console.log("Migrated " + promises.length + " keys successfully!");
if (inPlace) {
console.log("Deleting old keys");
return RSVP.all([
return Promise.all([
setWithPromise(fromFirebase.child('l'), null),
setWithPromise(fromFirebase.child('i'), null),
]);
Expand Down
2 changes: 1 addition & 1 deletion migration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"rsvp": "3.0.9",
"es6-shim": "0.34.x",
"firebase": "1.0.x"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
],
"dependencies": {
"firebase": "2.x.x",
"rsvp": "3.1.x"
"es6-shim": "0.34.x"
},
"devDependencies": {
"coveralls": "2.11.4",
"gulp": "3.9.0",
"bower": "1.7.x",
"gulp-concat": "2.6.0",
"gulp-ext-replace": "0.2.0",
"gulp-jshint": "1.11.2",
Expand Down
4 changes: 2 additions & 2 deletions src/geoFire.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var GeoFire = function(firebaseRef) {
}
});

return new RSVP.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
function onComplete(error) {
if (error !== null) {
reject("Error: Firebase synchronization failed: " + error);
Expand All @@ -84,7 +84,7 @@ var GeoFire = function(firebaseRef) {
*/
this.get = function(key) {
validateKey(key);
return new RSVP.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
_firebaseRef.child(key).once("value", function(dataSnapshot) {
if (dataSnapshot.val() === null) {
resolve(null);
Expand Down
4 changes: 2 additions & 2 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<script src="../bower_components/jasmine/lib/jasmine-core/boot.js"></script>
<link rel="stylesheet" href="../bower_components/jasmine/lib/jasmine-core/jasmine.css">

<!-- RSVP -->
<script src="../bower_components/rsvp/rsvp.min.js"></script>
<!-- ES6 (Promise) Shim -->
<script src="../bower_components/es6-shim/es6-shim.min.js"></script>

<!-- Firebase -->
<script src="../bower_components/firebase/firebase.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function generateRandomString() {

/* Returns the current data in the Firebase */
function getFirebaseData() {
return new RSVP.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
firebaseRef.once("value", function(dataSnapshot) {
resolve(dataSnapshot.exportVal());
});
Expand All @@ -82,7 +82,7 @@ function getFirebaseData() {

/* Returns a promise which is fulfilled after the inputted number of milliseconds pass */
function wait(milliseconds) {
return new RSVP.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
var timeout = window.setTimeout(function() {
window.clearTimeout(timeout);
resolve();
Expand Down