Skip to content

Official recommendation for using Bluebird with async functions? #1434

@wearhere

Description

@wearhere

Hello folks. First off I recognize that (despite your support guidelines) I am asking a support question, that has already received an answer on Stack Overflow. But a disadvantage of that channel is that I can't tell if that's an "official" recommendation or just some random user trying to be helpful.

I also feel like this discussion should be documented somewhere on bluebirdjs.com, whereas currently async functions don't get any mention there. (Closest is a mention of C#'s async functionality on Promise.coroutine. But what about in JS? async/await have been natively supported for multiple versions of V8 now.)

So—do the Bluebird maintainers have any position on the best way to use Bluebird with async functions, with an eye to functionality and/or performance? Suggestions:

  • somehow cause async functions to return instances of Bluebird promises rather than native promises? (Noting that changing global.Promise is not sufficient as shown here and here. It sounds like this guy may have found a way to do this but he doesn't show his code unfortunately. I have a comment pending on that post, we'll see.)
  • wrap async functions in Bluebird.method?
  • use a Babel plugin like this to convert async methods into Bluebird's coroutine and method helpers?

Related: #1426 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions