Message from JavaScript discussions

April 2017

— Nothig showed up


Yes, a promise is for deferred execution, it is supposed to yield to the next highest execution context

— And your promise does nothing

— Yeah, it does nothing but I'm trying to understand where it is executed.

— Read about continuation monads


new Promise(function (res, rej) {
console.log("I run right away");
res("I run after everything");
}).then(function (data) {
console.log("I run after");

VM361:2 I run right away
VM361:7 I run after
VM361:5 I run after everything

Message permanent page

— So, it always block.

— And its better no to use Sync versions

— The promise is created, runs it's callback, then yields to next highest context. then is run after resolve is run but only after that next highest context is finished

Message permanent page

— There is not new Promise alternative pattern

— Keep in mind those do not exist in regular js promises

— So the construct has highly varying uses between node vs browser js