with Firebase
Marlena Baker
baker.marlena@gmail.com git/baker-marlena
Data stored as JSON object
flexible database
access directly with Firebase’s GUI
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase-database.js"></script>var config = {
apiKey:
databaseURL:
};
firebase.initializeApp(config);const database = firebase.database();currentSession = database.ref(sessionKey);currentSession.child("timer")
currentSession.child(otherUser)session_data : {
user_1:{
textInput:"",
wordCount:0
},
user_2:{
textInput:"",
wordCount:0
}
};database.ref(session_key).set(session_data);let update = {
[userName]: {
textInput: this.value,
wordCount: wordCountValue
}
};
currentSession.update(update);currentSession.update({startStatus:false});currentSession.child(otherUser)
.on("value", (snapshot) => {
const data = snapshot.val();
return data.wordCount;
});
-> 23
currentSession.child('initilized')
.once('value')
.then(function(snapshot){
let data = snapshot.val();
return data;
};
-> falsecurrentSession.child('timeLeft').off();baker-marlena/realtime-demo
Marlena Baker
baker.marlena@gmail.com git/baker-marlena