Skip to content

Motivation for moving to Promises

Keheliya Gallaba edited this page Aug 4, 2017 · 1 revision

GitHub discussions about using Promises

Goal: Identify reasons why developers decide to use or not to use Promises over callbacks.

Method: Search popular JavaScript GitHub repositories for discussions

The search query used: promise callback language:Javascript stars:>30 comments:>5

Search Result: 4,342 issues

Full Results: link

Some selected results:

Examples from GitHub issues

The search query used: Refactor promises language:Javascript stars:>20 type:issue

Search Result: 351 issues

Full Results: link

Some selected results:

There is too much error-handling noise.
Use promises to clean up the code. Do not expose a promise-based api, though.

now that promises are going mainstream, i'm trying to think of how to make express more async friendly. an idea is to use promises.

Are there any plans for Promise support, alongside the callbacks and streams? Proper Promise support in any-db and any-db-transaction would be really nice :)

Do you have any plans to support Promise in the official client driver? I've made one for my own projects (aerospike-p), but, I guess many others have the same needs.

Just curious if there will be support for promises in the plugin and/or why they were left out?

Me too believe Promises are the future, but it seems that you need to make the users aware of what Promise library they should use or native browser Promises if supported.

This will be much better to use promises in your library.

Just wanted to check what your attitude towards using promises to manage asynchronous calls in decking is. We've recently converted pretty large internal codebases from async.js to promises and the code became smaller, more declarative, and cleaner at the same time.

So this is something that is purely for devs but I think it is about time to do this. i.e. git-task is a great candidate to take full advantage of promises and it would have made implementation of #602 much easier.

Since promises will be native in ES6 and currently methods do not return to anything important, we could return a Promise using any polyfill. Opinions?

Methods should return a Promise.

Any plans on following Promises/A+ spec?

Support native promises node.js and most browsers already have native support for promises.

Add promise support

Support promises

Native promises are already supported in nodejs 0.12. I think all methods should return promise.

Return Promise. If native ES6 promise available.

add a new promise aware api.

Add promise API option?

Mongoose supports promises natively. Would be helpful if mongoose-pages did too.

Examples from Git commits / pull requests

The search query used: Refactor promises language:Javascript stars:>20 type:pr

Search Result: 451 Pull Requests

Full Results: link

Some selected results:

Add promise support for the http object

Add support for promises on req.login

These changes enable the use of promises in migrations. For example..

any interest into converting the library to use promises?

return promise?

It would be awesome if you could merge this pull request to load bluebird promise support. I wrote a test case for it as well.

appended an exec() method to Request, thus will return a Promise object.

Promises

Added promise support in drawTaskHandler

Promises Refactor

We'd like to change getDriver() so that it can optionally return a promise. This would be useful for cases where asynchronous operations need to run before the driver can be returned.