Skip to content
This repository was archived by the owner on Mar 31, 2018. It is now read-only.
This repository was archived by the owner on Mar 31, 2018. It is now read-only.

util.toCallback(asyncFn) - interop of async functions with callbacks. #6

Closed

Description

@benjamingr

Similar to #5 I'm looking at ways to make the lives of callback users easier with async/await landing. I'm wondering if core should provide a method called toCallback that takes an async function and converts it to a callback returning function. This is similar to asCallback except taking a function:

async function fooP() {
    // some async/await stuff
    // ...
    return "Hello"; 
}
const foo = util.toCallback(fooP);

foo((err, data) => console.log(data)); // hello

The name and where it is are both debatable.

Activity

  1. chrisdickinson commented on Feb 15, 2016

    @chrisdickinson
    Contributor

    Does anyone object to making this issue non-blocking for the Promises PR?

  2. benjamingr commented on Feb 15, 2016

    @benjamingr
    MemberAuthor

    This issue is orthogonal (and certainly non-blocking) for the promises-in-core PR. It is only about async functions being more ergonomic to callback users.

  3. chrisdickinson commented on Feb 15, 2016

    @chrisdickinson
    Contributor

    Excellent! Did you see callbackify in the existing PR?

  4. chrisdickinson commented on Feb 15, 2016

    @chrisdickinson
    Contributor

    Would you object to discussing a public util.promisify in this issue, or would you prefer to keep that separate?

  5. benjamingr commented on Feb 17, 2016

    @benjamingr
    MemberAuthor

    Well, there are different stakeholders so I'd rather keep them separate. It seems like a generally good idea to keep discussions small to include participation. I don't feel very strongly about it though.

  6. benjamingr commented on Jul 4, 2017

    @benjamingr
    MemberAuthor

    This landed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions