You are reading a single comment by @luwar and its replies. Click here to read the full conversation.
  • 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
    });
    
About

Avatar for luwar @luwar started