Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Allow to use promises along with callback #32

Open
wtrocki opened this issue Aug 20, 2017 · 0 comments
Open

Allow to use promises along with callback #32

wtrocki opened this issue Aug 20, 2017 · 0 comments

Comments

@wtrocki
Copy link
Member

wtrocki commented Aug 20, 2017

Motivation

Suggestions from community:
Allow fh-sync-js to be promisified, by verifying and correcting api.
Provide promisified version of the api (separate for compatibility with the old one.

Quote from: #29

agree that we shouldn't mix promises in occasionally. The API should support one or the other, or both, but not a half-hearted mix. And for the record, promisify won't work with most sync (and other FH) functions, as they don't follow the standard single function (err, result) format.

That being said, my professional opinion is that you guys are going to be on the wrong side of history in callbacks vs promises. Most (popular, larger) libraries I see, if they support callbacks, generally support promises as well: if you provide a callback, it'll use that, otherwise it'll return a Promise. mongodb does this. It's really trivial if the inner workings of your library are promise-based, but mongodb also accomplishes it even though most of their internals are callback-based.

In my experience with people I've talked to, callbacks are generally deemed "legacy code" these days. There's a reason the mz library has nearly a million downloads per month. request-promise has double that. In addition to all the benefits of promises that Evan and I have probably stated ad nauseam, native async/await is just around the corner. Many shops have already been using them successfully with either Babel or TS, and callbacks-only API is completely incompatible with them."

Tasks

  • Change callback definitions to in order to be promissified on demand.
  • Provide promise based api
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant