Skip to content

Investigate supporting Promises and Callbacks #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
abmusse opened this issue Mar 4, 2021 · 3 comments
Open

Investigate supporting Promises and Callbacks #322

abmusse opened this issue Mar 4, 2021 · 3 comments
Labels
keep-open Exempts stale action from auto closing the issue/pr.

Comments

@abmusse
Copy link
Member

abmusse commented Mar 4, 2021

...

Lingering questions:

...

  • I see that everything is returning callback functions, and I have emulated that behavior. It is possible to have functions use callbacks or Promises, similar to how I do in the odbc package. Just check to see if a callback was passed as the final parameter, and if not, go to a Promise workflow. This would ensure API stability with anyone currently using the package, but would also allow developers to use the more modern Promise syntax.

Originally posted by @markdirish in #151 (comment)

@markdirish
Copy link
Contributor

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
Copy link
Member Author

abmusse commented Mar 4, 2021

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

Some of our transports support promises:

  • odbc
  • idb-connector -> idb-pconnector

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.

@abmusse abmusse added the keep-open Exempts stale action from auto closing the issue/pr. label Mar 11, 2021
@brandonp42
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep-open Exempts stale action from auto closing the issue/pr.
Projects
None yet
Development

No branches or pull requests

3 participants