Skip to content

Instantly share code, notes, and snippets.

@drewrothstein
Created July 11, 2020 05:27
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 drewrothstein/bf9c458467d73970b57adab60ca66b1c to your computer and use it in GitHub Desktop.
Save drewrothstein/bf9c458467d73970b57adab60ca66b1c to your computer and use it in GitHub Desktop.
.then() gets pretty old pretty fast
Promise.resolve(skipPosting)
.then((res) => {
if ( res === 'skipPosting' ) {
throw new Error('skipPosting');
}
})
.then(() => {
const fromTs = ...;
let countOfQuestions = ...;
queryQuestions.get().then((querySnapshot) => {
querySnapshot.forEach((documentSnapshot) => {
countOfQuestions += 1;
});
})
.then(() => {
if (countOfQuestions === 0) {
msg.push(`...`);
}
})
.then(() => {
let countOfAnswered = 0;
queryHero.get().then((querySnapshot) => {
querySnapshot.forEach((documentSnapshot) => {
const isResolvedAction = ...;
if (isResolvedAction) {
countOfAnswered += 1;
// ...
}
});
}).then(() => {
...
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment