diff --git a/.gitignore b/.gitignore
index e958edc..1ed1764 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-node_modules
-bower_components
-firebase.json
+dist/
+node_modules/
+bower_components/
tests/coverage
diff --git a/.travis.yml b/.travis.yml
index be7e49d..f81f0ac 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,4 +6,4 @@ install:
- npm install
- bower install
script:
-- npm test
\ No newline at end of file
+- npm run travis
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index f3cafba..0000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,46 +0,0 @@
-v0.1.6
--------------
-Release Date: 2014-06-29
-
- * Fixed issue when binding to Firebase limit() query
- * Added error checking
- * Added basic test suite
- * Added distribution files to Firebase CDN
- * Change Bower package name to reactfire (used to be ReactFire)
-
-v0.1.5
--------------
-Release Date: 2014-05-23
-
- * Used safe isArray() function thanks to @mjackson
-
-v0.1.4
--------------
-Release Date: 2014-05-13
-
- * Added node.js support
-
-v0.1.3
--------------
-Release Date: 2014-05-03
-
- * Bug fix for misnamed variable in _toArray() method (submitted by @danielmahal)
- * Added gulp integration to lint, minify, and test code
-
-v0.1.2
--------------
-Release Date: 2014-05-02
-
- * Fixed typo in bower.json
-
-v0.1.1
--------------
-Release Date: 2014-05-02
-
- * Better implementation of _isArray() and _toArray() helpers
-
-v0.1.0
--------------
-Release Date: 2014-04-30
-
- * First stable release of the ReactFireMixin
\ No newline at end of file
diff --git a/README.md b/README.md
index 4c73075..a28a4f3 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,17 @@
# ReactFire
-[](https://travis-ci.org/firebase/reactfire)
+[](https://travis-ci.org/firebase/reactfire)
[](http://badge.fury.io/gh/firebase%2Freactfire)
-[ReactJS](http://facebook.github.io/react/) is a framework for building large, complex user interfaces. [Firebase](http://www.firebase.com/?utm_source=reactfire) complements it perfectly by providing an easy-to-use, realtime data source for populating the `state` of React components. With ReactFire, it only takes a few lines of JavaScript to integrate Firebase into React apps via the `ReactFireMixin`.
+[ReactJS](http://facebook.github.io/react/) is a framework for building large, complex user
+interfaces. [Firebase](http://www.firebase.com/?utm_source=reactfire) complements it perfectly
+by providing an easy-to-use, realtime data source for populating the `state` of React components.
+With ReactFire, it only takes a few lines of JavaScript to integrate Firebase into React apps via
+the `ReactFireMixin`.
-[Read our blog post](https://firebase.com/blog/2014-05-01-using-firebase-with-react.html?utm_source=reactfire) on using Firebase with React and [check out our live Todo app demo](https://reactfiretodoapp.firebaseapp.com/) to get started!
+[Read our blog post](https://firebase.com/blog/2014-05-01-using-firebase-with-react.html?utm_source=reactfire)
+on using Firebase with React and [check out our live Todo app demo](https://reactfiretodoapp.firebaseapp.com/)
+to get started!
## Downloading ReactFire
@@ -17,15 +23,20 @@ In order to use the `ReactFireMixin` in your project, you need to include the fo
-
+
```
-Use the URL above to download both the minified and non-minified versions of ReactFire from the Firebase CDN. You can also download them from the `/dist/` directory of this GitHub repository. [Firebase](https://www.firebase.com/docs/web-quickstart.html?utm_source=reactfire) and [React](http://facebook.github.io/react/downloads.html) can be downloaded directly from their respective websites.
+Use the URL above to download both the minified and non-minified versions of ReactFire from the
+Firebase CDN. You can also download them from the
+[releases page of this GitHub repository](https://github.com/firebase/reactfire/releases).
+[Firebase](https://www.firebase.com/docs/web/quickstart.html?utm_source=geofire-js) and
+[React](http://facebook.github.io/react/downloads.html) can be downloaded directly from their
+respective websites.
-You can also install ReactFire via npm or Bower and the dependencies will be downloaded automatically:
+You can also install ReactFire via npm or Bower and its dependencies will be downloaded automatically:
```bash
$ npm install reactfire --save
@@ -37,7 +48,8 @@ $ bower install reactfire --save
## Getting Started with Firebase
-ReactFire requires Firebase in order to store data. You can [sign up here](https://www.firebase.com/signup/?utm_source=reactfire) for a free account.
+ReactFire requires Firebase in order to store data. You can
+[sign up here](https://www.firebase.com/signup/?utm_source=reactfire) for a free account.
## Usage
@@ -56,7 +68,8 @@ The following APIs will then be available from the `this` object inside of `Exam
### bindAsArray(firebaseRef, bindVar)
-Creates a binding between Firebase and the inputted bind variable as an array. The Firebase reference will be stored in `this.firebaseRefs[bindVar]`.
+Creates a binding between Firebase and the inputted bind variable as an array. The Firebase
+reference will be stored in `this.firebaseRefs[bindVar]`.
```javascript
var firebaseRef = new Firebase("https:///");
@@ -65,7 +78,8 @@ this.bindAsArray(firebaseRef, "items");
### bindAsObject(firebaseRef, bindVar)
-Creates a binding between Firebase and the inputted bind variable as an object. The Firebase reference will be stored in `this.firebaseRefs[bindVar]`.
+Creates a binding between Firebase and the inputted bind variable as an object. The Firebase
+reference will be stored in `this.firebaseRefs[bindVar]`.
```javascript
var firebaseRef = new Firebase("https:///");
@@ -74,7 +88,9 @@ this.bindAsObject(firebaseRef, "items");
### unbind(bindVar)
-Removes the binding between Firebase and the inputted bind variable. This removes the stored Firebase reference in `this.firebaseRefs[bindVar]` and cleans up any event handlers associated with that Firebase reference.
+Removes the binding between Firebase and the inputted bind variable. This removes the stored
+Firebase reference in `this.firebaseRefs[bindVar]` and cleans up any event handlers associated
+with that Firebase reference.
```javascript
this.unbind("items");
@@ -82,7 +98,8 @@ this.unbind("items");
## Contributing
-If you'd like to contribute to ReactFire, you'll need to run the following commands to get your environment set up:
+If you'd like to contribute to ReactFire, you'll need to run the following commands to get your
+environment set up:
```bash
$ git clone https://github.com/firebase/reactfire.git
@@ -94,6 +111,9 @@ $ bower install # install local JavaScript dependencies
$ gulp watch # watch for source file changes
```
-`gulp watch` will watch for changes in the `/src/` directory and lint, concatenate, and minify the source files when a change occurs. The output files - `reactfire.js` and `reactfire.min.js` - are written to the `/dist/` directory.
+`gulp watch` will watch for changes in the `/src/` directory and lint, concatenate, and minify the
+source files when a change occurs. The output files - `reactfire.js` and `reactfire.min.js` - are
+written to the `/dist/` directory.
-You can run the test suite by navigating to `file:///path/to/reactfire/tests/index.html` or via the command line using `gulp test`.
\ No newline at end of file
+You can run the test suite by navigating to `file:///path/to/reactfire/tests/index.html` or via the
+command line using `gulp test`.
\ No newline at end of file
diff --git a/bower.json b/bower.json
index 3021f5d..469e9ad 100644
--- a/bower.json
+++ b/bower.json
@@ -1,7 +1,7 @@
{
"name": "reactfire",
"description": "Firebase mixin for ReactJS",
- "version": "0.1.6",
+ "version": "0.0.0",
"authors": [
"Firebase "
],
@@ -29,7 +29,7 @@
"firebase.json",
"package.json",
"gulpfile.js",
- "release.sh"
+ "changelog.txt"
],
"dependencies": {
"react": "~0.10.0",
diff --git a/build/header b/build/header
index f94cae5..c1a33dc 100644
--- a/build/header
+++ b/build/header
@@ -1,10 +1,12 @@
-// ReactFire is an officially supported ReactJS mixin for Firebase. Firebase
-// provides your React app with a persistent, realtime backend to effortlessly
-// keep all of your clients in sync!
-//
-// ReactFire 0.1.6
-// https://github.com/firebase/reactfire/
-// License: MIT
+/*!
+ * ReactFire is an open-source JavaScript library that allows you to add a
+ * realtime data source to your React apps by providing and easy way to let
+ * Firebase populate the state of React components.
+ *
+ * ReactFire 0.0.0
+ * https://github.com/firebase/reactfire/
+ * License: MIT
+ */
var ReactFireMixin = (function() {
"use strict";
\ No newline at end of file
diff --git a/changelog.txt b/changelog.txt
new file mode 100644
index 0000000..e69de29
diff --git a/dist/reactfire.js b/dist/reactfire.js
deleted file mode 100755
index ae726e4..0000000
--- a/dist/reactfire.js
+++ /dev/null
@@ -1,142 +0,0 @@
-// ReactFire is an officially supported ReactJS mixin for Firebase. Firebase
-// provides your React app with a persistent, realtime backend to effortlessly
-// keep all of your clients in sync!
-//
-// ReactFire 0.1.6
-// https://github.com/firebase/reactfire/
-// License: MIT
-
-var ReactFireMixin = (function() {
- "use strict";
-var ReactFireMixin = {
- /********************/
- /* MIXIN LIFETIME */
- /********************/
- /* Initializes the Firebase binding refs array */
- componentWillMount: function() {
- this.firebaseRefs = {};
- },
-
- /* Removes any remaining Firebase bindings */
- componentWillUnmount: function() {
- for (var key in this.firebaseRefs) {
- if (this.firebaseRefs.hasOwnProperty(key)) {
- this.unbind(key);
- }
- }
- },
-
-
- /*************/
- /* BINDING */
- /*************/
- /* Creates a binding between Firebase and the inputted bind variable as an array */
- bindAsArray: function(firebaseRef, bindVar) {
- this._bind(firebaseRef, bindVar, true);
- },
-
- /* Creates a binding between Firebase and the inputted bind variable as an object */
- bindAsObject: function(firebaseRef, bindVar) {
- this._bind(firebaseRef, bindVar, false);
- },
-
- /* Creates a binding between Firebase and the inputted bind variable as either an array or object */
- _bind: function(firebaseRef, bindVar, bindAsArray) {
- this._validateBindVar(bindVar);
-
- var error;
- if (typeof firebaseRef.ref === "undefined" || firebaseRef.ref() instanceof Firebase === false) {
- error = "firebaseRef must be an instance of Firebase";
- }
- else if (typeof bindAsArray !== "boolean") {
- error = "bindAsArray must be a boolean. Got: " + bindAsArray;
- }
-
- if (typeof error !== "undefined") {
- throw new Error("ReactFire: " + error);
- }
-
- this.firebaseRefs[bindVar] = firebaseRef.ref();
- firebaseRef.on("value", function(dataSnapshot) {
- var newState = {};
- if (bindAsArray) {
- newState[bindVar] = this._toArray(dataSnapshot.val());
- }
- else {
- newState[bindVar] = dataSnapshot.val();
- }
- this.setState(newState);
- }.bind(this));
- },
-
- /* Removes the binding between Firebase and the inputted bind variable */
- unbind: function(bindVar) {
- this._validateBindVar(bindVar);
-
- if (typeof this.firebaseRefs[bindVar] === "undefined") {
- throw new Error("unexpected value for bindVar. \"" + bindVar + "\" was either never bound or has already been unbound");
- }
-
- this.firebaseRefs[bindVar].off("value");
- delete this.firebaseRefs[bindVar];
- },
-
-
- /*************/
- /* HELPERS */
- /*************/
- /* Validates the name of the variable which is being bound */
- _validateBindVar: function(bindVar) {
- var error;
-
- if (typeof bindVar !== "string") {
- error = "bindVar must be a string. Got: " + bindVar;
- }
- else if (bindVar.length === 0) {
- error = "bindVar must be a non-empty string. Got: \"\"";
- }
- else if (bindVar.length > 768) {
- // Firebase can only stored child paths up to 768 characters
- error = "bindVar is too long to be stored in Firebase. Got: " + bindVar;
- }
- else if (/[\[\].#$\/\u0000-\u001F\u007F]/.test(bindVar)) {
- // Firebase does not allow node keys to contain the following characters
- error = "bindVar cannot contain any of the following characters: . # $ ] [ /. Got: " + bindVar;
- }
-
- if (typeof error !== "undefined") {
- throw new Error("ReactFire: " + error);
- }
- },
-
-
- /* Returns true if the inputted object is a JavaScript array */
- _isArray: function(obj) {
- return (Object.prototype.toString.call(obj) === "[object Array]");
- },
-
- /* Converts a Firebase object to a JavaScript array */
- _toArray: function(obj) {
- var out = [];
- if (obj) {
- if (this._isArray(obj)) {
- out = obj;
- }
- else if (typeof(obj) === "object") {
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- out.push(obj[key]);
- }
- }
- }
- }
- return out;
- }
-};
- return ReactFireMixin;
-})();
-
-// Export ReactFireMixin if this is being run in node
-if (typeof module !== "undefined" && typeof process !== "undefined") {
- module.exports = ReactFireMixin;
-}
\ No newline at end of file
diff --git a/dist/reactfire.min.js b/dist/reactfire.min.js
deleted file mode 100755
index 5fbedb1..0000000
--- a/dist/reactfire.min.js
+++ /dev/null
@@ -1 +0,0 @@
-var ReactFireMixin=function(){"use strict";var e={componentWillMount:function(){this.firebaseRefs={}},componentWillUnmount:function(){for(var e in this.firebaseRefs)this.firebaseRefs.hasOwnProperty(e)&&this.unbind(e)},bindAsArray:function(e,n){this._bind(e,n,!0)},bindAsObject:function(e,n){this._bind(e,n,!1)},_bind:function(e,n,t){this._validateBindVar(n);var i;if("undefined"==typeof e.ref||e.ref()instanceof Firebase==!1?i="firebaseRef must be an instance of Firebase":"boolean"!=typeof t&&(i="bindAsArray must be a boolean. Got: "+t),"undefined"!=typeof i)throw new Error("ReactFire: "+i);this.firebaseRefs[n]=e.ref(),e.on("value",function(e){var i={};i[n]=t?this._toArray(e.val()):e.val(),this.setState(i)}.bind(this))},unbind:function(e){if(this._validateBindVar(e),"undefined"==typeof this.firebaseRefs[e])throw new Error('unexpected value for bindVar. "'+e+'" was either never bound or has already been unbound');this.firebaseRefs[e].off("value"),delete this.firebaseRefs[e]},_validateBindVar:function(e){var n;if("string"!=typeof e?n="bindVar must be a string. Got: "+e:0===e.length?n='bindVar must be a non-empty string. Got: ""':e.length>768?n="bindVar is too long to be stored in Firebase. Got: "+e:/[\[\].#$\/\u0000-\u001F\u007F]/.test(e)&&(n="bindVar cannot contain any of the following characters: . # $ ] [ /. Got: "+e),"undefined"!=typeof n)throw new Error("ReactFire: "+n)},_isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},_toArray:function(e){var n=[];if(e)if(this._isArray(e))n=e;else if("object"==typeof e)for(var t in e)e.hasOwnProperty(t)&&n.push(e[t]);return n}};return e}();"undefined"!=typeof module&&"undefined"!=typeof process&&(module.exports=ReactFireMixin);
\ No newline at end of file
diff --git a/examples/todoApp/firebase.json b/examples/todoApp/firebase.json
new file mode 100644
index 0000000..778ac70
--- /dev/null
+++ b/examples/todoApp/firebase.json
@@ -0,0 +1,4 @@
+{
+ "firebase": "reactfiretodoapp",
+ "public": "."
+}
diff --git a/gulpfile.js b/gulpfile.js
index 5682563..d104910 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -71,7 +71,9 @@ gulp.task("scripts", function() {
.pipe(gulp.dest(paths.scripts.dest.dir))
// Minify
- .pipe(uglify())
+ .pipe(uglify({
+ preserveComments: "some"
+ }))
// Rename file
.pipe(concat(paths.scripts.dest.files.minified))
@@ -97,5 +99,8 @@ gulp.task("watch", function() {
gulp.watch(["build/*", paths.scripts.src.dir + "/**/*"], ["scripts"]);
});
+/* Builds the distribution files */
+gulp.task("build", ["scripts"]);
+
/* Runs the "test" and "scripts" tasks by default */
gulp.task("default", ["test", "scripts"]);
\ No newline at end of file
diff --git a/package.json b/package.json
index 0ad823b..99fe023 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "reactfire",
"description": "Firebase mixin for ReactJS",
- "version": "0.1.6",
+ "version": "0.0.0",
"author": "Firebase (https://www.firebase.com/)",
"homepage": "https://github.com/firebase/reactfire/",
"repository": {
@@ -28,7 +28,6 @@
"dist/**",
"LICENSE",
"README.md",
- "CHANGELOG.md",
"package.json"
],
"dependencies": {
@@ -51,6 +50,7 @@
"jshint-stylish": "^0.2.0"
},
"scripts": {
- "test": "gulp test"
+ "test": "gulp test",
+ "travis": "gulp"
}
}
diff --git a/release.sh b/release.sh
deleted file mode 100755
index dbdd4e1..0000000
--- a/release.sh
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/bin/bash
-
-STANDALONE_DEST="../firebase-clients/libs/reactfire"
-STANDALONE_STUB="reactfire"
-
-
-#############################
-# VALIDATE reactfire REPO #
-#############################
-# Ensure the checked out reactfire branch is master
-CHECKED_OUT_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')"
-if [[ $CHECKED_OUT_BRANCH != "master" ]]; then
- echo "Error: Your reactfire repo is not on the master branch."
- exit 1
-fi
-
-# Make sure the reactfire branch does not have existing changes
-if ! git --git-dir=".git" diff --quiet; then
- echo "Error: Your reactfire repo has existing changes on the master branch. Make sure you commit and push the new version before running this release script."
- exit 1
-fi
-
-####################################
-# VALIDATE firebase-clients REPO #
-####################################
-# Ensure the firebase-clients repo is at the correct relative path
-if [[ ! -d $STANDALONE_DEST ]]; then
- echo "Error: The firebase-clients repo needs to be a sibling of this repo."
- exit 1
-fi
-
-# Go to the firebase-clients repo
-cd ../firebase-clients
-
-# Make sure the checked-out firebase-clients branch is master
-FIREBASE_CLIENTS_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')"
-if [[ $FIREBASE_CLIENTS_BRANCH != "master" ]]; then
- echo "Error: Your firebase-clients repo is not on the master branch."
- exit 1
-fi
-
-# Make sure the firebase-clients branch does not have existing changes
-if ! git --git-dir=".git" diff --quiet; then
- echo "Error: Your firebase-clients repo has existing changes on the master branch."
- exit 1
-fi
-
-# Go back to starting directory
-cd -
-
-##############################
-# VALIDATE CLIENT VERSIONS #
-##############################
-# Get the version we are releasing
-PARSED_CLIENT_VERSION=$(head -5 dist/reactfire.js | tail -1 | awk -F ' ' '{print $3}')
-
-# Ensure this is the correct version number
-read -p "What version are we releasing? ($PARSED_CLIENT_VERSION) " VERSION
-if [[ -z $VERSION ]]; then
- VERSION=$PARSED_CLIENT_VERSION
-fi
-echo
-
-# Ensure the changelog has been updated for the newest version
-CHANGELOG_VERSION="$(head -1 CHANGELOG.md | awk -F 'v' '{print $2}')"
-if [[ $VERSION != $CHANGELOG_VERSION ]]; then
- echo "Error: Most recent version in changelog (${CHANGELOG_VERSION}) does not match version you are releasing (${VERSION})."
- exit 1
-fi
-
-# Ensure the README has been updated for the newest version
-README_VERSION="$(grep '