IBM / nodejs-itoolkit

A JavaScript (Node.js) library for communicating with IBM i
MIT License
42 stars 37 forks source link

Investigate supporting Promises and Callbacks #322

Open abmusse opened 3 years ago

abmusse commented 3 years ago

...

Lingering questions:

...

Originally posted by @markdirish in https://github.com/IBM/nodejs-itoolkit/issues/151#issuecomment-790747341

markdirish commented 3 years ago

I should mention that this isn't a pattern I've seen elsewhere, but it seems to work well. It is similar to packages that "promisify" callback APIs. I think the official Node APIs just create separate "promise" versions of functions, but that seems too verbose to myself.

abmusse commented 3 years ago

I think the main function that utilizes the callback pattern is Connection.run.

Some of our transports support promises:

While others would need adjusting / alternatives:

For the http transport I'm sure we could find a promise based alternative. The ssh transport is a little more tricky as ssh2 seems to only be event driven at the moment with no promise support.

brandonp42 commented 11 months ago

Hi @abmusse and @markdirish is this still under consideration? I would be very interested in using this with ODBC along with #320