Message from JavaScript discussions

April 2017

— 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

— 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

— You will find completely different uses between them

— Yes, this is the last playground I used and give me the light, DO NOT RUN IT, It will block the REPL.

Promise.resolve().then(() => {
setTimeout(() => console.log('Time is out'), 100)

Message permanent page

— Hehe

— Because before I used the new Promise, and I had the power to cancel, but i'm not in power after the .then runs in the next tick

Message permanent page