Skip to content

Instantly share code, notes, and snippets.

@jeromeetienne
Created June 25, 2017 16:00
Show Gist options
  • Save jeromeetienne/84285edd7675076a03bc60e3bbb39bac to your computer and use it in GitHub Desktop.
Save jeromeetienne/84285edd7675076a03bc60e3bbb39bac to your computer and use it in GitHub Desktop.
firebase - example - one webpage sending data to another
<script src="https://www.gstatic.com/firebasejs/4.1.3/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
// YOUR CONFIG goes here - https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
};
var firebaseApp = firebase.initializeApp(config);
var rootRef = firebase.database().ref();
// Get a reference to the /users/ada node
var adaRef = firebase.database().ref("users/ada");
adaRef.on('value', function(snapshot){
console.log('latency', Date.now() - snapshot.val().time);
});
</script>
<script src="https://www.gstatic.com/firebasejs/4.1.3/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
// YOUR CONFIG goes here - https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
};
var firebaseApp = firebase.initializeApp(config);
var rootRef = firebase.database().ref();
// Get a reference to the /users/ada node
var adaRef = firebase.database().ref("users/ada");
adaRef.set({
arApp: 'loaded'
});
setInterval(function(){
console.log('time')
adaRef.set({
time : Date.now()
});
}, 100)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment