Skip to content

Instantly share code, notes, and snippets.

@koistya
Last active December 17, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koistya/de59f4dfae77591e6ede1bccc3b8a102 to your computer and use it in GitHub Desktop.
Save koistya/de59f4dfae77591e6ede1bccc3b8a102 to your computer and use it in GitHub Desktop.
Doing common JavaScript tasks without Redux https://medium.com/p/f23ffbbb02ae
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