When using promises, they run automatically without being called. I followed the MDN Docs on setting them up, and they run when they are declared, without being prompted.
var progressPromise = new Promise(function(resolve, reject) {
// Query the DB to receive the ToDo tasks
// inProgress is the tableID
getTasks(inProgress, function(tasks) {
// Check that the list is returned.
console.log("Shouldn't Run Automatically");
if (tasks) {
console.log("This Too Runs Automatically");
resolve(tasks);
} else {
reject("There was a failure, the data was not received");
}
});
});
<p>Console Output</p>
<p> Shouldn't Run Automatically </p>
<p> This too runs automatically </p>
I've checked the remaining code, only the promises trigger when I start the app with node index.js
Is this by design, or is my implementation wrong? If it's by design it would be great if you could link me to the docs, because I was unable to find anything on it.
Thank you!