Skip to content

Instantly share code, notes, and snippets.

@romanonthego
Last active July 2, 2017 04:26
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 romanonthego/9cec0f80441cab2b016cf08636280468 to your computer and use it in GitHub Desktop.
Save romanonthego/9cec0f80441cab2b016cf08636280468 to your computer and use it in GitHub Desktop.
// 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