Skip to content
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

Document how to turn callbacks into promises using bluebird #606

Closed
rayshan opened this issue Jun 18, 2014 · 11 comments
Closed

Document how to turn callbacks into promises using bluebird #606

rayshan opened this issue Jun 18, 2014 · 11 comments
Labels

Comments

@rayshan
Copy link

rayshan commented Jun 18, 2014

Many may find this bluebird feature useful if they're looking for a redis library that supports promises or manually turning callbacks into promises:

var Promise = require("bluebird");
Promise.promisifyAll(require("redis"));
var db = redis.createClient...
db.getAsync(key).then()
...

More details
https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification

@zacharynevin
Copy link

Ditto. I almost exclusively use promises now.

@brycebaril
Copy link
Contributor

I'm not a promise user myself, but if you were to write up a blog post or detailed gist on how this library works when using promises (Especially if it demonstrates more than just one Promises implementation) I would be happy to link it from the Readme!

@zacharynevin
Copy link

Sure I would be happy to do that. Also, have you considered making node_redis compatible with the Promise.promisifyAll function on Bluebird? https://github.com/petkaantonov/bluebird/blob/master/API.md#promisepromisifyallobject-target--object-options---object

Zachary Nevin

@rayshan
Copy link
Author

rayshan commented Jun 21, 2014

I've been using bluebird with no issues (see original comment), though I've only used about 10 methods or so. What's not compatible?

@zacharynevin
Copy link

I probably just did something wrong. I got the "doesn't have a method 'then' "error.

Zachary Nevin

On Jun 21, 2014, at 3:09 PM, Ray Shan [email protected] wrote:

I've been using bluebird with no issues (see original comment), though I've only used about 10 methods or so. What's not compatible?


Reply to this email directly or view it on GitHub.

@rayshan
Copy link
Author

rayshan commented Jun 24, 2014

Are you using 2.x? In 1.x you have to promisifyAll a newed instance of redis. In 2.x this one line works for me:

Promise.promisifyAll(require("redis"));

@zacharynevin
Copy link

Yeah it works for me now.

@komocode
Copy link

Do you have an example on how to use the multi as promises?

@maxbrieiev
Copy link

For multi only exec should return a promise. This lib handles it for you: https://github.com/maxbrieiev/promise-redis

See the very last paragraph.

@blainsmith
Copy link
Contributor

In order to better support this project and its new group of collaborators under a new org we are trying to clean up and close issues older than 6 months. Your issue may have been fixed since the issue was open, however, if you are still experiencing a problem please re-open this issue and we will label it accordingly.

@BridgeAR
Copy link
Contributor

Reference #864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants