dpcs: Update Docs for realtime listeners (#3778)

[skip-ci]
This commit is contained in:
Arpit Banati
2020-06-15 13:40:05 +05:30
committed by GitHub
parent 2821001d6d
commit e1922cd2b3

View File

@@ -98,10 +98,10 @@ import database from '@react-native-firebase/database';
function User({ userId }) {
useEffect(() => {
const subscriber = database();
ref(`/users/${userId}`).on('value', snapshot => {
console.log('User data: ', snapshot.val());
});
const subscriber = database()
.ref(`/users/${userId}`).on('value', snapshot => {
console.log('User data: ', snapshot.val());
});
// Stop listening for updates when no longer required
return () => subscriber();
@@ -124,10 +124,10 @@ import database from '@react-native-firebase/database';
function User({ userId }) {
useEffect(() => {
const subscriber = database();
ref('/users').on('child_added', snapshot => {
console.log('A new node has been added', snapshot.val());
});
const subscriber = database()
.ref('/users').on('child_added', snapshot => {
console.log('A new node has been added', snapshot.val());
});
// Stop listening for updates when no longer required
return () => subscriber();