Created
February 5, 2017 19:05
-
-
Save kumarmj/42ef8ac3596b68aecbbb098f2693758f to your computer and use it in GitHub Desktop.
Getting Started on web with firebase realtime database https://www.youtube.com/watch?v=dBscwaqNPuk&list=PLl-K7zZEsYLmnJ_FpMOZgyg6XcIGBu2OX&index=3
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 characters
(function(){ | |
// Initialize firebase | |
const config = { | |
} | |
firebase.initializeApp(config); | |
// Get Elements | |
const preObject = document.getElementById("object"); | |
const uList = document.getElementById(""); | |
// Create References | |
const dbRefObject = firebase.database().ref().child('Object'); | |
const dbRefList = dbRefObject.child("hobbies"); | |
// Sync object changes | |
dbRefObject.on('value', snap => { | |
preObject.innerText = = JSON.stringify(snap.val(), null, 3); | |
}); | |
// Synch List changes | |
dbRefList.on('child-added', snap => { | |
const li = document.createElement('li'); | |
li.innerText = snap.val(); | |
uList.appendChild(li); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment