Message from JavaScript discussions

April 2017

— I really want to understand this

— 

This?

new Promise((resolve, reject) => {
setImmediate(() => {
console.log("Then run");
resolve()
})
})
console.log("Running loop");
for(var i = 0; i < 100; i++) {
console.log("Blocking");
};

— 

new Promise(function (resolve, reject) {

    resolve("Hello World");

}).then(function (data) {

    console.log(data); // "Hello World!"

}).catch(function (exception) {

    console.error(exception);

}).then(function (data) {

    // This runs on both resolve & reject

});

Message permanent page

— Ok, I'm back

— Are you using node promises?

— Yes

— Me?

— I was referring to just the plain jane js promises which differ a few ways

— Lmao, I tried this, and it blocked right away.

new Promise((resolve, reject) => {
while(true);
})
console.log('Then')
setTimeout(() => console.log('Time is out'), 100)

Message permanent page

— Nothig showed up

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

Message permanent page

— And your promise does nothing