Last active
March 4, 2016 00:04
-
-
Save anantn/4325052 to your computer and use it in GitHub Desktop.
Revisions
-
anantn revised this gist
Feb 13, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ function makeList(ref) { } function getFirstFromList(ref, cb) { ref.startAt().limit(1).once("child_added", function(snapshot) { cb(snapshot.val()); }); } -
anantn created this gist
Dec 18, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ function makeList(ref) { var fruits = ["banana", "apple", "grape", "orange"]; for (var i = 0; i < fruits.length; i++) { ref.push(fruits[i]); } } function getFirstFromList(ref, cb) { ref.startAt().limit(1).on("child_added", function(snapshot) { cb(snapshot.val()); }); } // Running this should popup an alert with "banana". function go() { var testRef = new Firebase("https://example.firebaseIO-demo.com/"); makeList(testRef); getFirstFromList(testRef, function(val) { alert(val); }); }