Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const syncData = (props, dispatch) =>
firebase.app(props.database)
.firestore()
.collection(props.collection)
.doc(props.key)
.onSnapshot(doc => {
console.log("Received update from firebase!", doc.data())
props.actions.map(action =>
dispatch(action, {
document: doc.data()
})
)
}, e => {
console.error("Error querying resource", e)
dispatch(props.error, {e});
})
export function _firebaseAppFactory(config: FirebaseAppConfig, appName?: string): FirebaseApp {
try {
if (appName) {
return firebase.initializeApp(config, appName) as FirebaseApp;
} else {
return firebase.initializeApp(config) as FirebaseApp;
}
}
catch (e) {
if (e.code === "app/duplicate-app") {
return firebase.app(e.name) as FirebaseApp;
}
return firebase.app(null!) as FirebaseApp;
}
}
export function _firebaseAppFactory(config: FirebaseAppConfig, appName?: string): FirebaseApp {
try {
if (appName) {
return firebase.initializeApp(config, appName) as FirebaseApp;
} else {
return firebase.initializeApp(config) as FirebaseApp;
}
}
catch (e) {
if (e.code === "app/duplicate-app") {
return firebase.app(e.name) as FirebaseApp;
}
return firebase.app(null!) as FirebaseApp;
}
}