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 fetchEmployees = () => { const {currentUser} = firebase.auth(); return (dispatch) => { firebase.database().ref(`/users/${currentUser.uid}/employees`) .on('value', (snapshot) => { dispatch({type: FETCH_EMPLOYEE_SUCCESS, payload: snapshot.val()}) }); //TODO catch error } }
componentDidMount() { const firebaseRef = firebase.database().ref(this.props.firebaseRef); firebaseRef.on('value', snapshot => { let val = snapshot.val(); this.setState({ data: snapshot.val() }); }); }
componentWillMount() { const { uid } = firebaseAuth.currentUser; this.getArtistRef().on('value', snapshot => { const artist = snapshot.val() if (artist) { this.setState({ likeCount: artist.likeCount, liked: artist.likes && artist.likes[uid] }); } }); }
componentDidMount() { this.firebaseDateRef.on('value', snapshot => { this.props.userActions.loadUserInfo(this.props.match.params.uid, snapshot.val()); this.setState({ loading: false }); }) }
const setListener = (endpoint, updaterFn) => { firebase .database() .ref(endpoint) .on('value', updaterFn); return () => firebase .database() .ref(endpoint) .off(); }
export function watchFirebaseTicketsRef() { return function(dispatch) { tickets.on("child_added", data => { const newTicket = Object.assign({}, data.val(), { id: data.getKey(), formattedWaitTime: new Moment(data.val().timeOpen).from(new Moment()) }); dispatch(receiveTicket(newTicket)); }); }; }
componentDidMount() { this.getArtistCommentsRef().on('child_added', this.addComment); }
connectedRef.on("value", function(snap) { if (snap.val() === true) { console.log('connected bitch'); } else { console.log('fuck shit disconnected'); } });
componentWillMount() { const { uid } = firebaseAuth.currentUser this.getArtistRef().on('value', snapshot => { const artist = snapshot.val() if (artist) { this.setState({ liked: artist.likes && artist.likes[uid], likeCount: artist.likeCount }) } }) }
db.ref('.info/connected').on('value',function(snap){ if(snap.val() === true) console.log('Connected to firebase'); else console.log('Disconnected from firebase'); });
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(); }