I would like to use the new Promise API introduced in 1v86 but I'm not able to get even the simplest scenarios to work.
Should the Espruino promises work like the normal ES6 promises?
The following code should output 1 1 2 4 but does 1 1 1 1. A bug or a feature? ;-)
var p = new Promise( function(resolve) { resolve(1); });
p.then( function(value) {
console.log(value); // 1
return value + 1;
}).then( function(value) {
console.log(value); // 2
return new Promise( function( resolve ) { resolve( 4 ); } );
}).then( function( value ) {
console.log( value ); // 4
} );
p.then(function(value) {
console.log(value); // 1
});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I would like to use the new Promise API introduced in 1v86 but I'm not able to get even the simplest scenarios to work.
Should the Espruino promises work like the normal ES6 promises?
The following code should output 1 1 2 4 but does 1 1 1 1. A bug or a feature? ;-)