15. REALLY easy.
Write Data
Firebase ref = new Firebase("https://.....firebaseio.com/");
ref.setValue("Hello, Video Hackers!");
Read Data
ref.on("value", function (snapshot) {
var data = snapshot.val();
console.log(data);
});
24. @saturnism
<!-- 1. Include Firebase JS Client -->
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js">
</script>
Step 1 - Include Firebase Client Library
25. @saturnism
// 2. Create a Firebase reference.
var myDataRef =
new Firebase('https://blinding-heat-8328.firebaseio.com/');
Step 2 - Create a Firebase Reference
26. @saturnism
// 3. Push a message when "Send" is clicked.
myDataRef.set({
name: "Bret",
text: "Hello, world!"
});
Step 3 - Save the Data
27. @saturnism
// 3. Push a message when "Send" is clicked.
myDataRef.set({
name: textboxName,
text: textboxMessage
});
Step 3 - Save the Data
28. @saturnism
// 3. Push a message when "Send" is clicked.
myDataRef.push({
name: textboxName,
text: textboxMessage
});
Step 3 - Save the Data
29. @saturnism
// 4. Listen to the child_added event, and display the message.
myDataRef.on("child_added", function (snapshot) {
var firebaseValue = snapshot.val();
displayChatMessage(firebaseValue.name, firebaseValue.text);
});
Step 4 - Listen to new data