Last active
August 29, 2015 14:10
-
-
Save spasiu/70f5c829b668c1c3ebb8 to your computer and use it in GitHub Desktop.
firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//creating a firebase object | |
var datafire = new Firebase('https://purchases.firebaseio.com'); | |
//a listener that watches the firebase server for changes to our object and executes a callback | |
//I guess we're going to need to generate one when a user logs in so they can watch only their object for changes | |
datafire.on('value', function(snapshot){ | |
var firedata = snapshot.val(); | |
console.log(firedata); | |
}); | |
//pushing data to our firebase object | |
datafire.set({"UID":"soAndSo"}); //sample data | |
//api calls we're going to have to service | |
getConnections(callback); //--> [{uid: "", name: ""}, {uid: "", name: ""}, {uid: "", name: ""}] OR false | |
getName(uid, callback); //--> name OR false | |
postTransaction(obj, uid, callback); //--> uid is optional, if present mutates obj to contain logged in user's uid in "to" attribute inserts obj into user UID's transaction array, otherwise inserts unmutated object into authenticated user's transaction array. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe this is what we're looking for:
"Child Changed
This event will be triggered when the data stored in a child (or any of its descendants) changes. Note that a single child_changed event may represent multiple changes to the child. The DataSnapshot passed to the callback will contain the new child contents. For ordering purposes, the callback is also passed a second argument which is a string containing the name of the previous sibling child by priority order (or null if it is the first child)."
firebaseRef.on('child_changed', function(childSnapshot, prevChildName) {
// code to handle child data changes.
});