I try use promise, but it's work strange:
const p = new Promise(function(resolve, reject) { setTimeout(resolve, 100); setTimeout(reject, 200); }); p.then(function() { console.log('resolved'); }).catch(function() { console.log('rejected'); });
output:
resolved Uncaught Error: Unhandled promise rejection: undefined
Bolded text printed, because reject called after resolve, but promise must be ignore change state at second call.
And what about async\await?
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 try use promise, but it's work strange:
output:
Bolded text printed, because reject called after resolve, but promise must be ignore change state at second call.
And what about async\await?