You are reading a single comment by @nhlives and its replies. Click here to read the full conversation.
  • Thanks, the PROMISE is available on the 8266 and does work mostly. I would like to create the promise here:

    wifi.on('connected',(details) => {
    var clearQueuePromise = new Promise((resolve,reject) => { --http stuff-- }
    });
    

    However, that blows up with nothing in the way of useful information. If I just create the promise outside of the wifi.on, and let it fail until the WiFi connection completes it does what I want although a bit messy.

    var clearQueuePromise = new Promise((resolve,reject) => {
      idClearQueue = setInterval(() => {
           idClearQueue = setInterval(() => {
               --do http GET until successful---
              clearInterval(idClearQueue);
             resolve("OK");
           },2000);
    });
    

    And then

    wifi.on('connected', (details) => {
    clearQueuePromise.then((resolve,reject) => {
        print('clear queue finished');
      });
     // This initiates the main loop 
        idMainLoop = setInterval(mainLoop, 2000);
    

    Critical comments are welcome :-)

About

Avatar for nhlives @nhlives started