Created
June 25, 2017 16:00
-
-
Save jeromeetienne/84285edd7675076a03bc60e3bbb39bac to your computer and use it in GitHub Desktop.
firebase - example - one webpage sending data to another
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
<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> |
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
<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