GithubHelp home page GithubHelp logo

Comments (7)

davidjamesstone avatar davidjamesstone commented on June 17, 2024 1

Thanks for that link, I hadn't seen it before and didn't know about the next/callback naming convention.

I guess you do get used to it though I'm not sure it's entirely clear to newcomers to hapi-land.

My concern for glue is It means that code could break/behaviour change if an async plugin is introduced at a later date.

E.g. This test code is good until an async plugin is registered in the manifest, after which module.exports would not be initialized:

Glue.compose(manifest, options, (err, server) => {
  if (!module.parent) {
    server.start(() => {
      console.log('Server started on port:', server.info.uri);
    });
  } else {
    module.exports = server;
  }
});

I see your labbable addresses this 👍

from glue.

csrl avatar csrl commented on June 17, 2024 1

I think the short term "fix" is to change 'callback' to 'next' in glue.compose.

Regardless of server.register behavior, if glue.compose is called with a manifest that has an empty registrations, it still needs to maintain async behavior if the compose parameter is to be called 'callback', if we are to abide by the style guide.

from glue.

csrl avatar csrl commented on June 17, 2024

I'm thinking this would be considered a breaking change and require a major version bump. Opinions?

from glue.

devinivy avatar devinivy commented on June 17, 2024

I agree that it would be a breaking change. Given that it's accepted for hapi plugins to behave sync or async, it's pretty hard for me to say whether I agree with this change or not. I definitely agree that it's preferable for async-looking things to behave asynchronously. But a change here almost implies that server.register() itself should be changed, which is hard for me to agree with outright.

from glue.

davidjamesstone avatar davidjamesstone commented on June 17, 2024

I'd like to see server.register change. This issue then goes away but that's probably much harder to change I guess, and has more implications.

FWIW, I think it's still a worthwhile (breaking) change for glue.
Writing plugins has always feel async-ish to me, given you need to call next ala expressjs.

...just my 2 cents

from glue.

devinivy avatar devinivy commented on June 17, 2024

Worth adding, the hapi style guide is at least clear on the point that callbacks named next are the only ones that may occur before the next tick: http://hapijs.com/styleguide#callback. That does mean that plugins themselves don't have to follow the next-tick rule. I suppose server.register() would be the next in line to ensure the rule is followed. It's a toss-up for me, but I'm pretty accustomed to hapi's behavior here!

from glue.

lock avatar lock commented on June 17, 2024

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

from glue.

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.