Today's EmberFire release includes new features that will make it even easier for Ember developers to connect their apps to Firebase. The EmberFire 1.5.0 release brings Ember Data 1.13.0 compatibility, integration with Firebase Authentication, and some updates for embedded records.
What is EmberFire?
EmberFire is an adapter for using Firebase with Ember Data. It is packaged as an Ember CLI addon, which makes it incredibly easy to add Firebase as the backend for your Ember app. Using EmberFire, all of your models stored in Ember Data will be automatically synchronized with our remote Firebase database. Simply calling save() on a record will save it to the store and persist that data in your Firebase database.
New Features in EmberFire 1.5.0
Ember Data 1.13.0 Compatibility
Ember Data has made it out of beta, which means we can count on a stable API. This is great news for EmberFire. In addition to 1.13.0 compatibility, we're working on staying up to date with the latest releases, and our tests are also passing for 2.0 canary!
Torii Authentication
You can now authenticate users in your EmberFire app with Facebook, Twitter, GitHub, and Google using our Torii adapter. Get started by enabling the authentication provider you’d like to use in your Firebase Dashboard, installing the Torii addon, and following the authentication section in our guide. Once you've set it up, you can authenticate a user inside your route or controller with the following snippet:
This release also changes the way embedded records are declared. If you have an embedded hasMany / belongsTo relationship in your EmberFire app, you should now follow the Ember Data conventions by configuring embedded record settings in a serializer. Visit the relationships section of our guide for details. Just be sure to use Ember Data 1.13.6+ for embedded records compatibility.
Getting Started
If you're new to EmberFire, using it with your Ember CLI app is as simple as installing our addon:
ember install emberfire
Then, update your Firebase URL in config/environment.js and you're ready to persist your Ember Data records in your Firebase database. Check out our guide for a detailed walkthrough on all things EmberFire.
We'd love to hear what you think of the latest release. Post any feedback in our Ember Google Group, or open an issue on GitHub. Contributions to EmberFire are always welcome, so feel free to submit a pull request if there's something you'd like to see added.
We're excited to see what you build with Firebase and Ember!
React and Firebase were made for each other. And with the introduction of ReactFire
back in May 2014, we provided a simpler way to build apps using both technologies. Today we're
announcing ReactFire 0.5.0 - the biggest update since that initial release. The update brings
improved performance, a handful of bug fixes, and some extra features to simplify development.
What is ReactFire?
For those who aren't familiar, ReactFire is a React mixin. The ReactFireMixin makes it dead
simple to bind data stored in Firebase to a component's state. It handles both array-like and
object-like data via the bindAsArray() and bindAsObject() methods, respectively.
For example, say you have a list of messages stored in your Firebase database that looks like this:
The message data is now bound to this.state.messages. Whenever messages are added, removed,
updated, or moved in Firebase, those changes are reflected automatically in this.state.messages
no calls to this.setState() required! The bound data can be used as normal in your component's render() method:
The 0.5.0 release is the first major upgrade to the ReactFireMixin since its initial release. The API is still just as minimal, but a lot has changed under the hood.
The initial implementation of bindAsArray() was quite simplistic. It had poor performance and did not properly handle complex Firebase queries. The new implementation provides improved performance (especially on large data sets) and works well with all Firebase queries. Best of all, no changes to your code are required to enable these improvements.
Another major change with 0.5.0 is the addition of the .key attribute. ReactFire now adds the
.key attribute to every record it creates via the bindAsArray() and bindAsObject() methods.
In previous versions, it was impossible to retrieve key names for bound items. The 0.5.0 release
fixes this by including the key name by adding a .key attribute to each bound item.
As an example, let's look again at the messages array from above. The resulting bound array stored in this.state.messages will be:
[
{
".key": "-JqpIO567aKezufthrn8", // New in version 0.5.0!
"uid": "barney",
"text": "Welcome to Bedrock City!"
},
{
".key": "-JqpIP5tIy-gMbdTmIg7", // New in version 0.5.0!
"uid": "fred",
"text": "Yabba dabba doo!"
}
]
The inclusion of .key makes it possible to easily write data back to Firebase to update,
remove, or move a record in the array. All objects synced via bindAsObject() now include the
.key attribute as well.
Finally, version 0.5.0 changes how primitive values (strings, numbers, booleans) are handled. As
an example, say you have the following data in your Firebase database:
{
"foo": "bar"
}
If you call bindAsObject() on the /foo/ path, previous versions bound the value as a string
"bar". As of today's 0.5.0 release, the bound object now looks like this:
{
".key": "foo",
".value": "bar"
}
You have access to the key that was bound to (.key) as well as the bound value (.value).
Primitive values bound via bindAsArray() behave in the same way with the primitive value being
stored in .value. Non-primitive values (that is, regular JavaScript objects) have not changed
and behave in the same in all versions, except for the addition of .key.
Looking Forward
There is a lot of excitement in the React community about ES6+, Relay, GraphQL, and ReactNative.
Discussions about these topics are even ongoing in the ReactFire GitHub
repo. We are following the new announcements
and technologies closely. Since we use React in production at Firebase, we want the two
technologies to work as well as possible together.
We've found that using the vanilla React and Firebase libraries together works great and somewhat
replaces the need for an application architecture like Flux. Things like ReactFire simplify
development further by providing a shorthand for a lot of common use cases. And community
contributions like the recently released re-base
library show how well Firebase can fit into new technologies like Relay. The future of a React +
Firebase application tech stack is exciting and promising. The two technologies make it that much
easier to build scalable apps in a fraction of the time they traditionally have taken. You can
expect ReactFire to evolve alongside React over the course of the comings months.
Getting Started with ReactFire
The best place to get started with ReactFire is by heading over to the docs.
We have a five minute quickstart, a guide which walks you through making an example app, and a
full API reference with more examples of binding data via bindAsArray() and bindAsObject().
If you run across any bugs or have feature suggestions, please file them on
GitHub. If you have questions about the API or how to
build apps with ReactFire, post them on the Firebase Google
Group.