Coder Social home page Coder Social logo

emberfire's Introduction

EmberFire

Ember.js and Firebase Integration

This library provides a base Ember.js model that does the retrieving and syncing of your object's property to your specific Firebase location.

Installation

Just add the "emberfire.js" file in your html.

<script type="text/javascript" src="./emberfire.js"></script>

Example usage

Sample Firebase location data:

/myapp
  - person
    - firstName: "Juan"
    - lastName: "Pedro"
    - age: "17"
    - address: "Manila"

[Step 1]
To have an Ember.js model that is Firebase-location-aware, you just have to extend the "EmberFire" model:

Person = EmberFire.extend({});

[Step 2]
Provide these properties to give default values:

  • locationUrl -- property to specify your firebase location.
  • isListItem -- default is false property to tell if this firebase location a list item or not.
  • listId -- needed if isListItem is set to true and it is already existing in the firebase location.
  • modelProperties -- property to enumerate the firebase location properties.
var firebaseLocation = "/myapp";

Person = EmberFire.extend({
  locationUrl: firebaseLocation + "/person",
  modelProperties: ["firstName", "lastName", "age", "address"]
});

[Step 3]
Once you are done specifying this configuration you can "optionally" add your own properties to your Ember.js model and specify their default values:

Person = EmberFire.extend({
  locationUrl: firebaseLocation + "/person",
  modelProperties: ["firstName", "lastName", "age", "address"]

  firstName: "",
  lastName: "",
  age: 0,
  address: ""
});

[Step 4]
And then you can create an instance of your model and it will automatically sync any updates on your Ember.js model.

window.App = Ember.Application.create();
App.person = Person.create();

If you want to delete the whole model on your Firebase location just call the "remove()" method.

App.person.remove();

emberfire's People

Contributors

maiah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

emberfire's Issues

Not working with latest firebase version

Wanted to try Ember with Firebase but your module doesn't seem to work. I've change the url in emberfire.js to xxx.firebaseio.com still not luck?

Do you plan to update it to the latest firebase version?

Cheers,
S

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.