Last active
December 17, 2017 20:34
-
-
Save koistya/de59f4dfae77591e6ede1bccc3b8a102 to your computer and use it in GitHub Desktop.
Doing common JavaScript tasks without Redux https://medium.com/p/f23ffbbb02ae
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '@firebase/auth'; | |
import firebase from '@firebase/app'; | |
const callbacks = new Set(); | |
export default { | |
signIn() { | |
const provider = new firebase.auth.FacebookAuthProvider(); | |
return firebase.auth().signInWithPopup(provider); | |
}, | |
signOut() { | |
return firebase.auth().signOut(); | |
}, | |
showLoginDialog() { | |
callbacks.forEach(cb => cb()); | |
}, | |
onShowLoginDialog(cb) { | |
callbacks.add(cb); | |
return () => { callbacks.delete(cb); }; | |
}, | |
onAuthStateChanged(cb) { | |
firebase.auth().onAuthStateChanged(cb); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment