changeVideoBtn1(){ firebase.database().ref().child('react').child('videoID').child('vid1').once('value').then(snap =>{ this.setState({ videoID: snap.val() }); }) }
const fetchFavoriteQuotes = () => { return firebase.database().ref(QUOTES_COLLECTION).once('value'); }
test('Should remove expense from firebase', (done) => { const store = createMockStore(defaultAuthState); const id = expenses[0].id store.dispatch(startRemoveExpense({ id })).then(() => { const actions = store.getActions(); expect(actions[0]).toEqual({ type: 'REMOVE_EXPENSE', id }) return database.ref(`users/${uid}/expenses/${id}`).once('value'); }).then((snapshot) => { expect(snapshot.val()).toBeFalsy(); done(); }) });
async function isUsernameTaken(username) { return !!(await db.ref(`users/${username}`).once("value")).val(); }
componentDidMount() { // prefetch data to only recieve callbacks on new data added let initialDataLoaded = false; this.reactionsRef.once('value', snapshot => { initialDataLoaded = true; // set initial data to always be up to date if data is stored in localstorage this.setReactions(snapshot.val()); }); // on value change, update state and reactions this.reactionsRef.on('value', snapshot => { // if initalData is not loaded, return if (!initialDataLoaded) return; // else update reactions with new data this.setReactions(snapshot.val()); }); }
const startSetExpenses = () => { return (dispatch, getState) => { const uid = getState().auth.uid; return database.ref(`users/${uid}/expenses`).once('value').then((snapshot) => { const expenses = []; snapshot.forEach((childSnapshot) => { expenses.push({ id: childSnapshot.key, ...childSnapshot.val() }); }); dispatch(setExpenses(expenses)); }); }; }
db.once('value',function(snap){ snap.forEach(function(childsnap){ var key = childsnap.key; var ref = db.child(key); ref.update({ "images" : "Yayyy" }); }); });
const fetchContinents = () => { return database.ref(apiUris.continents) .once('value') .then((snapshot) => { const continents = snapshot.val(); if (continents) { continents.forEach((continent) => { continent.regions.sort((a, b) => { return a.name > b.name; }) }); } return continents || []; }); }
componentDidMount() { // prefetch data to only recieve callbacks on new data added let initialDataLoaded = false; this.pollRef.once('value', snapshot => { initialDataLoaded = true; this.updatePoll(snapshot.val()); this.setState({ initialDataLoaded }); }); // on value change, update state and poll this.pollRef.on('value', snapshot => { // if initalData is not loaded, return if (!initialDataLoaded) return; this.updatePoll(snapshot.val()); }); }
const fetchPlaceDetail = (placeId) => { return database.ref(getPlaceDetailUri(placeId)) .once('value') .then((snapshot) => { const placeDetail = snapshot.val(); placeDetail.reviews = placeDetail.reviews ? placeDetail.reviews = Object.keys(placeDetail.reviews) .map((key, index) => { const review = placeDetail.reviews[key]; review.id = key; return review; }) : []; return placeDetail; }); }
changeVideoBtn2(){ firebase.database().ref().child('react').child('videoID').child('vid2').once('value').then(snap =>{ this.setState({ videoID: snap.val() }); }) }
changeVideoBtn3(){ firebase.database().ref().child('react').child('videoID').child('vid3').once('value').then(snap =>{ this.setState({ videoID: snap.val() }); }) }
componentDidMount() { // prefetch data to only recieve callbacks on new data added let initialDataLoaded = false; this.pollRef.once('value', snapshot => { initialDataLoaded = true; this.updatePoll(snapshot.val()); this.setState({ initialDataLoaded }); }); // on value change, update state and poll this.pollRef.on('value', snapshot => { // if initalData is not loaded, return if (!initialDataLoaded) return; this.updatePoll(snapshot.val()); }); }
test('should remove expense from firebase', (done) => { const store = createMockStore(defaultAuthState); const id = expenses[2].id; store.dispatch(startRemoveExpense({ id })).then(() => { const actions = store.getActions(); expect(actions[0]).toEqual({ type: 'REMOVE_EXPENSE', id }); return database.ref(`users/${uid}/expenses/${id}`).once('value'); }).then((snapshot) => { expect(snapshot.val()).toBeFalsy(); done(); }); });
componentDidMount() { // prefetch data to only recieve callbacks on new data added let initialDataLoaded = false; this.reactionsRef.once('value', snapshot => { initialDataLoaded = true; // set initial data to always be up to date if data is stored in localstorage this.setReactions(snapshot.val()); }); // on value change, update state and reactions this.reactionsRef.on('value', snapshot => { // if initalData is not loaded, return if (!initialDataLoaded) return; // else update reactions with new data this.setReactions(snapshot.val()); }); }