Code Monkey home page Code Monkey logo

Comments (3)

RubenVerborgh avatar RubenVerborgh commented on June 23, 2024 1

To clarify: Since the lib itself calls the function, it would be the lib passing the done callback into it. We would then have to check if the function expects a fourth argument. Is this what you meant by activating async by a done callback?

Yes; although probably 4 arguments wouldn't be great to have. But we can discuss/change that once we have concrete code.

For example: if a user for some reason has defined a beforeRedirect function with four expected arguments, things would work fine today.

Ah well they shouldn't, it wasn't in our interface 😅

Personally, I think the promise pattern is the cleanest one.

Yes, but follow-redirects has a long compatibility history, with even some earlier versions of Node that did not have promises yet. But feel free to take a first stab at it, and we can discuss it from there.

from follow-redirects.

RubenVerborgh avatar RubenVerborgh commented on June 23, 2024

Thanks @olebor, that makes sense. For backward compatibility, we could activate async support if either a done callback is passed as an argument or a promise is returned by the function.

from follow-redirects.

olebor avatar olebor commented on June 23, 2024

Cool!

To clarify: Since the lib itself calls the function, it would be the lib passing the done callback into it. We would then have to check if the function expects a fourth argument. Is this what you meant by activating async by a done callback?

Adding a fourth done parameter could potentially break some cases. For example: if a user for some reason has defined a beforeRedirect function with four expected arguments, things would work fine today. But if we were to add a function as the fourth argument and expect it to be called before proceeding, this case would stop functioning.

Am I missing something?

Personally, I think the promise pattern is the cleanest one.

from follow-redirects.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.