Yes, the issue is the event-driven nature of JS. I was looking for a way to write simpler code since there isn't a reliable async or Promise flow control library to use; I'll have to work with flags then. Some questions:
Do you know if http.createServer() returns a new instance with a listener every time it's invoked like node.js? Or is there code beneath the hood that will check for an existence of a http.Server object? I did a quick test to invoke http.createServer() twice in succession and there was no namespace conflicts or EADDRINUSE errors, nor did the callback trigger twice upon a POST to my ESP8266.
Does the Wifi class trigger an event when it has connected to a network? Something like Wifi.on('connected', function(){...}) -- Nevermind, found the docs: http://www.espruino.com/Reference#t_l_Wifi_connected
Is there a way to save a key/value pair to flash? (or just any variable)
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.
@Gordon:
ESP8266 NodeMCU 1.0 (ESP-12E)
Yes, the issue is the event-driven nature of JS. I was looking for a way to write simpler code since there isn't a reliable
async
orPromise
flow control library to use; I'll have to work with flags then. Some questions:Do you know if
http.createServer()
returns a new instance with a listener every time it's invoked like node.js? Or is there code beneath the hood that will check for an existence of ahttp.Server
object? I did a quick test to invokehttp.createServer()
twice in succession and there was no namespace conflicts orEADDRINUSE
errors, nor did the callback trigger twice upon a POST to my ESP8266.Does the Wifi class trigger an event when it has connected to a network? Something like
Wifi.on('connected', function(){...})
-- Nevermind, found the docs: http://www.espruino.com/Reference#t_l_Wifi_connectedIs there a way to save a key/value pair to flash? (or just any variable)