FirebaseExtended / firebase-queue

MIT License
787 stars 108 forks source link

Reject Continues #84

Closed ahaverty closed 7 years ago

ahaverty commented 7 years ago

I've noticed calling reject() doesn't end the worker/queue instantly. For example:

if(!myVar){
    reject();
}
console.log("my var exists if you got this far");

Having read and re-read the firebase-queue guide, this wasn't obvious to me. I've gotten around it by not relying on reject()

obvious example:

if(!myVar){
    reject();
} else {
    console.log("my var exists if you got this far");
}

Perhaps this was never the intention of reject(). But it may be useful to add or highlight this in the guide?

Currently on the following, if relevant:

   "firebase": "^3.4.1",
    "firebase-queue": "^1.5.0",
jwngr commented 7 years ago

This is actually expected behavior and exactly how Promises work. resolve() and reject() are just callback methods and calling them does not stop execution. You can solve this by either using the if / else blocks you mentioned or just doing return reject(); instead of just reject(). The return will ensure no code after it will be run:

if(!myVar){
  return reject();
}
console.log("my var exists if you got this far");