You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Nice! actually I guess the Puck.js library could be extended to return promises - it'd make an awful lot more sense. Although running promises on the Puck itself too is really neat, and neatly wraps around any calls to Espruino libraries that use Promises internally.

    It was always my intention to make UART.js (that thing I started in the Oxford hack day) use Promises, and to generally fix the dodgy APIs inherited from Puck.js. Sadly I never got around to it though :(

    The PuckWorker is a neat abstraction - although as you say maybe it actually makes things a bit harder as you've now got two separate files.

    Just a random thought, but it seems this works:

    function getBattery() { 
      return E.getBattery() 
    }
    Puck.eval("("+getBattery.toString()+")()­")
    

    So you could actually write JS code for Espruino alongside that for the browser (without having to encase it inside a string). It's nice from the point of view of syntax highlighting and linting anyway.

About

Avatar for Gordon @Gordon started