JamesBarwell / rpi-gpio.js

Control Raspberry Pi GPIO pins with node.js
MIT License
657 stars 116 forks source link

Promises #58

Closed thecodershome closed 6 years ago

thecodershome commented 7 years ago

Added promise object gpio.promise, which wraps setup, read, write, destroy in promises.

Example from last PR


var gpio = require('rpi-gpio.js'),
    gpio_p = gpio.promise;

gpio_p.setup(7, gpio.DIR_IN)
  .then(() => {
    return gpio_p.read(7)
  })
  .then((value) => {
    console.log('The value is ' + value);
  })
`
JamesBarwell commented 7 years ago

Excellent, this looks really good. Give me a little time to have a go myself and update the readme. I'll aim to get it merged in the next week.

ghost commented 7 years ago

Bump

johankj commented 6 years ago

Any updates @JamesBarwell?

JamesBarwell commented 6 years ago

My only update is to apologise for dawdling so much. I have just got back from a holiday and hope to get on to this very soon.

I'm also considering some kind of beta branch for this project so that PRs like this can be made available much more quickly.

JamesBarwell commented 6 years ago

This has been merged and published as 0.9.0.

Huge thanks for doing the work and many apologies again for being so slow to respond. I have various good excuses but I won't clutter the thread with my personal life!

I'm going to have a think about what to do for documentation and how much to push this new API. There's a very good case for this being the primary interface to the module, given how many users are new to node and struggle with the err-back functions.