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}`); } });
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 } }
const fetchToDos = () => async dispatch => { todosRef.on("value", snapshot => { dispatch({ type: FETCH_TODOS, payload: 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 }); }) }
componentWillMount() { const messagesRef = database.ref('messages') .orderByKey() .limitToLast(100); messagesRef.on('child_added', snapshot => { const message = { text: snapshot.val(), id: snapshot.key }; this.setState(prevState => ({ messages: [ message, ...prevState.messages ], })); }); }
connectedRef.on("value", function(snap) { if (snap.val() === true) { console.log('connected bitch'); } else { console.log('fuck shit disconnected'); } });
componentDidMount() { goalRef.on('value', snap => { let goals = []; snap.forEach(goal => { const { email, title } = goal.val(); const serverKey = goal.key; goals.push({ email, title, serverKey }); }) this.props.setGoals(goals); }) }
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 }) } }) }
componentDidMount() { goalRef.on('value',snap => { let goals = []; snap.forEach(goal => { const {email,title}= goal.val(); goals.push({email,title}); }) this.props.setGoals(goals); }) }
db.ref('.info/connected').on('value',function(snap){ if(snap.val() === true) console.log('Connected to firebase'); else console.log('Disconnected from firebase'); });
componentDidMount() { messageRef.on('value', snap => { let messages = []; snap.forEach(response => { let { message, author } = response.val(); messages.push({ message, author }); }) this.setState({messages: messages}); }) }
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}`); } });