I glanced over the module code... and even though I agree with the approach of using Promises to get over the asynchronous needs, you might resort to something much less elegant...
One of the main reasons is that Espruino runs off of the source code. The interpreter has to have a reasonable expression in JS to get to work. The highly elegant and correct solution with so many Promises in one single expression could render just to much for Espruino to deal with. I may be completely wrong, but I would use a simple sequencer / tasker / state machine to do that. I built something similar to overcome asynchronous calls in a sequence with retry support (yes, retry support can also be implemented in Promises, as I just very recently came across in the forum in order to break out/fail/reject after x timed retries, but again, it is within Promises and may pull in even more such):
I'm sure you try to save the code before even somethings started to run, correct?
© Espruino, powered by microcosm.
Report a problem