var promise = new Promise( function(resolve,reject) { resolve(); } );
Promise.all( [promise] ).then( function() { print( "never called :-(" ); } )
Does work. My guess is the reason you're having problems is you're doing this at the root scope - effectively pasting in one command after the other. In that case, var promise = new Promise( function(resolve,reject) { resolve(); } ); gets called first, and executes on its own. There's nothing linked to it so it just completes and everything is ok.
Then, when you do Promise.all, it's already been resolved so nothing happens. If you just wrap the two commands in curly braces or execute them in a function, everything's fine. I'll try and add something to cope with that eventuality.
As for the other bit, at the moment Promise.all doesn't return things in order - just in the order they complete. I'll try and fix that one too.
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.
Just looked at this, and:
Does work. My guess is the reason you're having problems is you're doing this at the root scope - effectively pasting in one command after the other. In that case,
var promise = new Promise( function(resolve,reject) { resolve(); } );
gets called first, and executes on its own. There's nothing linked to it so it just completes and everything is ok.Then, when you do
Promise.all
, it's already been resolved so nothing happens. If you just wrap the two commands in curly braces or execute them in a function, everything's fine. I'll try and add something to cope with that eventuality.As for the other bit, at the moment
Promise.all
doesn't return things in order - just in the order they complete. I'll try and fix that one too.