'How to continiously read data change from firebase realtime database in vue.js
I am using vue.js version 2 with cdn mode. I have created 2 vue components. One components is pushing the data to database and the other component will show it. Below is the code
firebase.database().ref().on('value', function (data) {
console.log("called");
console.log("data received " + JSON.stringify(data));
});
I want to read data continuously, but above method is not working. It reads the data only one time. How to solve this issue so that I can read the data continuously ?
Solution 1:[1]
I have done this in vue like this
import { onValue, ref as Ref} from "firebase/database";
onValue(Ref(db, path), (snapshot) => {
// you get value here
//snapshot.val());
});
// where db is the main Database reference
// and path is the path inside db
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
