Posted on
  • I saw an old thread referencing Promises, but can't seem to find an official Promise module anywhere. I tried an implementation by @favo from this thread but a simple console.log() test had erroneous results where callbacks occurred before resolutions.

    Trying to save a bit of time myself and hoping this was already implemented.

  • It's built-in to all the new firmwares:­e

    I guess you're using ESP8266 so I'm not sure if you're using a build that has it disabled or something, but on an official board with up to date firmware then it's just already there as soon as you type new Promise(...)

  • 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() {
    }).catch(function() {


    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?

  • I try use promise, but it's work strange

    This looks like a bug - I've filed one for the issue here:­ues/1433

    Looks like we didn't test for that as all code I've seen to date just calls one of the other - not both.

    And what about async\await?

    No, they're not implemented on Espruino.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview


Posted by Avatar for espftw @espftw