Comments (7)
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.
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.
I'm thinking this would be considered a breaking change and require a major version bump. Opinions?
from glue.
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.
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.
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.
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)
- How can I use standard modules as plugins? HOT 4
- how do you pass in concurrent option to hapi? HOT 4
- Should we have a "ISSUE_TEMPLATE.md" for Glue? HOT 1
- How should I use routes in server config (failAction). HOT 3
- Add hook to transform plugin list before registration HOT 17
- Integration with webpack - dynamic import issue HOT 4
- Make hapi a peer dependency HOT 7
- Error: Cannot start server before plugins finished registration HOT 4
- Using glue with hapi-mongoose HOT 5
- server.events is undefined after glue compose HOT 5
- Server options load support? Migrating from hapi 16 -> 17 HOT 6
- Change module namespace HOT 1
- Change module namespace for v5 branch HOT 1
- Server cache options in hapi 18 cannot be passed HOT 3
- Action required: Greenkeeper could not be activated 🚨 HOT 1
- Update deps HOT 1
- Update joi HOT 1
- Add typescript type definitions HOT 2
- Only node 12
- No way of passing default route validator to glue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glue.