Skip to content

Instantly share code, notes, and snippets.

@SastraNababan
Created March 7, 2018 09:10
Show Gist options
  • Save SastraNababan/451ded97012198ad6c0139d72bbd2a75 to your computer and use it in GitHub Desktop.
Save SastraNababan/451ded97012198ad6c0139d72bbd2a75 to your computer and use it in GitHub Desktop.
firebase config
import firebase from 'react-native-firebase'
const config = {
apiKey: "AIzaSyBiXJTuUD5Ya9PUM81l5qQ83bOZIAlvIGE",
authDomain: "react-native-73f21.firebaseapp.com",
databaseURL: "https://react-native-73f21.firebaseio.com",
projectId: "react-native-73f21",
storageBucket: "react-native-73f21.appspot.com",
messagingSenderId: "150783570753"
};
export const rootRef = firebase.app().database().ref()
export const itemsRef = rootRef.child('items');
export function syncFirebase(store) {
itemsRef.on('child_added', (snapshot) => {
console.log(snapshot.val())
// store.dispatch(addItemSuccess(snapshot.val()))
})
itemsRef.on('child_removed', (snapshot) => {
console.log(snapshot.val())
// store.dispatch(removeItemSuccess(snapshot.val().id))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment