-
-
Save thedevankit/0d9bec5c5b5c29acb0c34f17debed0d0 to your computer and use it in GitHub Desktop.
firebase - example - one webpage sending data to another
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
<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 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
<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