gifFirebaseRef.on('value', snapshot => { const gifURL = snapshot.val() || ''; // got the url, stop listening for changes if (gifURL) { gifFirebaseRef.off(); this.goOffline(); setMessage(''); this.setState( { gifFirebaseRef, gifURL, loading: false, processing: false }, () => { this.updateBackgroundColor(); this.updateAddThis(); }, ); } else if (!processing) { this.goOffline(); setMessage(''); // user opened by url // we saw if exists. it didnt. so lets redirect it to the main page push(`/#${subject}`); } });
//Fetch instances router.get('/', function (req, res) { const userReference = firebase.database().ref("/Users/"); //Attach an asynchronous callback to read the data userReference.on("value", function(snapshot) { console.log(snapshot.val()); res.json(snapshot.val()); userReference.off("value"); }, function (errorObject) { console.log("The read failed: " + errorObject.code); res.send("The read failed: " + errorObject.code); }); });
// on value change, update checkin status state checkinRef.on('value', snapshot => { if (!snapshot.hasChild('endTime')) { update.setActiveRoom(snapshot, response.data.checkinData, this.props, checkinID); } else checkinRef.off('value'); });
componentWillUnmount() { // clear all previous listeners this.pollRef.off('value'); }
const setListener = (endpoint, updaterFn) => { firebase .database() .ref(endpoint) .on('value', updaterFn); return () => firebase .database() .ref(endpoint) .off(); }
componentWillUnmount() { // clear all previous listeners this.reactionsRef.off('value'); }
gifFirebaseRef.on('value', snapshot => { const gifURL = snapshot.val() || ''; // got the url, stop listening for changes if (gifURL) { gifFirebaseRef.off(); this.goOffline(); setMessage(''); this.setState( { gifFirebaseRef, gifURL, loading: false, processing: false }, () => { this.updateBackgroundColor(); this.updateAddThis(); }, ); } else if (!processing) { this.goOffline(); setMessage(''); // user opened by url // we saw if exists. it didnt. so lets redirect it to the main page push(`/#${subject}`); } });
// on value change, update checkin status state checkinRef.on('value', snapshot => { if (!snapshot.hasChild('endTime')) { update.setActiveRoom(snapshot, response.data.checkinData, this.props, checkinID); } else checkinRef.off('value'); });
const setListener = (endpoint, updaterFn) => { firebase .database() .ref(endpoint) .on('value', updaterFn); return () => firebase .database() .ref(endpoint) .off(); }
componentWillUnmount() { // clear all previous listeners this.reactionsRef.off('value'); }
const setListener = (endpoint, updaterFn) => { firebase.database().ref(endpoint).on('value',updaterFn); return () => firebase.database().ref(endpoint).off(); }