Last active
July 2, 2017 04:26
-
-
Save romanonthego/9cec0f80441cab2b016cf08636280468 to your computer and use it in GitHub Desktop.
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
// before: | |
import firebase from 'what/ever/firebase' | |
const {auth} = firebase | |
export function signIn({email, password}) { | |
auth.signInWithEmailAndPassword(email, password) | |
.then((user) => { | |
// ... | |
}) | |
} | |
// --- | |
// after: | |
import firebase from 'what/ever/firebase' | |
export function signIn({email, password}) { | |
firebase().then(({auth}) => { | |
auth.signInWithEmailAndPassword(email, password) | |
.then((user) => { | |
// ... | |
}) | |
}) | |
} | |
// --- | |
// or a little less verbose version | |
function withFirebase(callback) { | |
return firebase().then(callback) | |
} | |
// ... | |
import {withFirebase} from 'what/ever/firebase' | |
export function signIn({email, password}) { | |
withFirebase(({auth}) => { | |
auth.signInWithEmailAndPassword(email, password) | |
.then((user) => { | |
// ... | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment